/    Sign up×
Community /Pin to ProfileBookmark

whats the problem with "document.write"

Hello

I have some problem with generating output from my javascript.

The problem is…

As soon as I use the document.write() command it seems like all variables and functions are reset and the variables/functions get “undefined” (?) I have earlier posted a topic

[url]http://www.webdeveloper.com/forum/showthread.php?t=110659[/url]

where I have noticed this problem… my questions are is there a known problem with this and is there a workaround?

Regards/D_S

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KorJun 22.2006 — Use dynamic methods instead of document.write()

Use [B]DOM methods[/B] or non-standard but fully crossbrowser method [B]innerHTML[/B]
Copy linkTweet thisAlerts:
@CharlesJun 22.2006 — The problem is that document.write starts a new document if you use it after the document is complete and the document stream is closed. Which makes sense, you're trying to write outside the HTML element.

Also, document.write doesn't - or shouldn't - work with XHTML at all.
×

Success!

Help @digital_storm 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 5.19,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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