/    Sign up×
Community /Pin to ProfileBookmark

IE shows this Perfect Firefox derrr.

Hello,I am doing this simple exercise of displaying some variables in document write statements to body of page.Like so as attachment.
In IE it works perfect but in firefox it gets stuck here.
Error
Error: Stock2 is not defined
Source File: file:///c:/Documents%20and%20Settings/Andrew/My%20Documents/Stocks.html
Line: 38

Why does Firefox complain here is the line.
document.writeln( “<h4>My Second stock choice is ” + Stock2 + “</h4>”);

It is defined in the document.Who can help me please?
Thank you

[upl-file uuid=8cb30337-6f08-4124-bc4b-33d63757782a size=65kB]stockstoforum.jpg[/upl-file]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangMar 15.2005 — document.writeln writes a new document, do not use it once the original document has been loaded.

IE processes the function then writes the requested lines in one go.

FF processes the function line for line. Does the first writeln, tries to do the second but the variable no longer exists in the new document.

Options:

1) Move the variables into the function

2) Process the function in the [i]body[/i]

3) Use [URL=http://www.mozilla.org/docs/dom/domref/]DOM methods[/URL]
Copy linkTweet thisAlerts:
@andyaleanauthorMar 15.2005 — Thank you will try.
×

Success!

Help @andyalean 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.6,
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,
)...