www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] proper tables in ie9 with doctype set

  1. #1
    Join Date
    Jul 2012
    Posts
    9

    resolved [RESOLVED] proper tables in ie9 with doctype set

    I have a page creating code for an iframe via javascript.
    I was using tables to line up my questions and answers and two buttons in an inner table. When I try and add doctype it screws up in ie9.
    Code:
    <html>
    <head>
    <script>
     var openbody='\<html lang="en"\>\n\<head\>\n\<meta charset="utf-8"\>\</meta\>\n\</head\>\n\<body\>\n';
     var closebody='\</body\>\n\</html\>';
    function make_html(tag,data,extra,newline){return_value="\<"+tag;if(extra!=""){return_value+=" "+extra;}return_value+="\>"+newline+data+"\</"+tag+"\>";return return_value;}
    function make_row(data,extra){return make_html("tr",make_html("td",data,extra,""),"","");}
    function dosomething(input)
    {
      var mycontentDocument=document.getElementById('mycontent').contentDocument;
      if(!mycontentDocument){mycontentDocument=document.frames['mycontent'].document;}
      var table=make_row("hello","")+"\n";
      table+=make_row("world","")+"\n";
      var innertable="\<tr\>\<td align='left'\>left\</td\>\<td align='right'\>right\</td\>\</tr\>\n";
      table+=make_row("\n"+make_html("table",innertable,"border=\"0\"","\n")+"\n","")+"\n";
      var output=input;
      output+=openbody;
      output+="hello world\n";
      output+=make_html("table",table,"border=\"0\"","\n")+"\n";
      output+=closebody;
      alert(output);
      mycontentDocument.body.innerHTML=output;
    }
    </script>
    </head>
    <body>
    <iframe id='mycontent' ></iframe><br>
    <input type="button" value="nonproper" onclick="dosomething('')">
    <input type="button" value="proper attempt" onclick="dosomething('<!DOCTYPE html>\n')">
    </body>
    </html>
    In IE9 when I press the nonproper button it works fine. When I press the proper attempt button it displays just "hello world" it works in compatibility mode. But I'd like to learn proper use of tables so that even IE9 is happy outside of compatibility mode.

  2. #2
    Join Date
    Aug 2006
    Posts
    1,908
    Have you tried the table as a "normal" html file without the iframe, and without spitting it out via JS? Seems like a good place to start the debugging. The only thing I notice is you're using "align=" which I suspect is not legal in html5. Possibly "border=" is also not legal.

    Dave

  3. #3
    Join Date
    Jul 2012
    Posts
    9
    Quote Originally Posted by tracknut View Post
    Have you tried the table as a "normal" html file without the iframe, and without spitting it out via JS? Seems like a good place to start the debugging. The only thing I notice is you're using "align=" which I suspect is not legal in html5. Possibly "border=" is also not legal.

    Dave
    Works fine as a normal table.
    If I copy the output to a webpage and view it it works fine.
    If I display that working page in an iframe it works fine.
    So this is an iframe issue in ie9 specific to how I load the iframe.
    I do not want to use the open write close method as I do not want the people using the sight to be able to go back.
    Everything works leaving out the doctype.

    I just tried the open write close method and it works the same.

    Ah Ha when I added <!doctype html> to the outer page it all works as expected.
    Last edited by jeffsadowski; 08-29-2012 at 04:36 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles