www.webdeveloper.com
Results 1 to 5 of 5

Thread: document.write() replacement statement in HTM5

  1. #1
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,354

    Question document.write() replacement statement in HTM5

    I read somewhere that HTML5 will not allow document.write() statements.

    The following script does use the document.write() statement and it seems to work to create a new window
    BUT, I get and error in the error console stating
    -----------------------------
    Timestamp: 12/9/2012 11:34:22 PM
    Warning: XUL box for _moz_generated_content_after element contained an inline #text child, forcing all its children to be wrapped in a block.
    Source File: chrome://browser/content/browser.xul
    Line: 0
    -----------------------------

    What is the appropriate statement to replace the document.write() to avoid the error reports?

    Code:
    <!doctype html5>
    <html>
    <head>
    <title>JS created window</title>
    <script type="text/javascript">
    function newHTML() {
     var HTMLstring='<HTML>\n';
     HTMLstring+='<HEAD>\n';
     HTMLstring+='<TITLE>New Document</TITLE>\n';
     HTMLstring+='</HEAD>\n';
     HTMLstring+='<BODY>\n';
     HTMLstring+='<P>Hello</P>\n';
     HTMLstring+='</BODY>\n';
     HTMLstring+='</HTML>';
     var newwindow=window.open("", "Window3", "width=320,height=210,scrollbars=yes");
    
     newwindow.document.write(HTMLstring);  // What is replacement statement for document.write() ???
    
    
     newwindow.document.close();
    }
    </script>
    </head>
    <body>
    <input type="button" value="New Window" onclick="newHTML();">
    </body>
    </html>

  2. #2
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    Quote Originally Posted by JMRKER View Post
    Source File: chrome://browser/content/browser.xul
    So clearly nothing to do with your code then...
    Where used, return should be executed unconditionally and always as the last statement in the function.

    That's my signature, it's not part of the damn post!

  3. #3
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,354
    OK, thanks. I had not noticed the "chrome" statement as I was using FF at the time.

    However, have you heard if the document.write() statement will be deprecated in HTML5?
    Or was that something I dreamed instead of read?

  4. #4
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    Quote Originally Posted by JMRKER View Post
    However, have you heard if the document.write() statement will be deprecated in HTML5?
    Or was that something I dreamed instead of read?
    I see no reason to deprecate document.write, nor do I see any direct connection between it and HTML5.
    Where used, return should be executed unconditionally and always as the last statement in the function.

    That's my signature, it's not part of the damn post!

  5. #5
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,354
    Thanks for your time.

Thread Information

Users Browsing this Thread

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

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