/    Sign up×
Community /Pin to ProfileBookmark

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”);

[COLOR=”#FF0000″] newwindow.document.write(HTMLstring); // What is replacement statement for document.write() ???
[/COLOR]

newwindow.document.close();
}
</script>
</head>
<body>
<input type=”button” value=”New Window” onclick=”newHTML();”>
</body>
</html>

[/code]

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@Logic_AliDec 10.2012 — 
Source File: chrome://browser/content/browser.xul
[/QUOTE]

So clearly nothing to do with your code then...
Copy linkTweet thisAlerts:
@JMRKERauthorDec 10.2012 — 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?
Copy linkTweet thisAlerts:
@Logic_AliDec 10.2012 — 
However, have you heard if the document.write() statement will be deprecated in HTML5?

Or was that something I dreamed instead of read?[/QUOTE]


I see no reason to deprecate document.write, nor do I see any direct connection between it and HTML5.
Copy linkTweet thisAlerts:
@JMRKERauthorDec 11.2012 — Thanks for your time.
×

Success!

Help @JMRKER spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...