/    Sign up×
Community /Pin to ProfileBookmark

Newbee: Function and loading in Firefox

Hi all!
I am all new to Java Script and have just started looking at functions.
I have jast made the simplest of scripts, (in a file called “simple.html”):
<html>
<head>
<SCRIPT LANGUAGE=”JavaScript”>
function simple()
{
document.write(“Simple”);
}
</SCRIPT>
</head>
<body><a href=”JavaScript:simple()”>CLICK</a></body>
</html>

As long as I do not use the function the script runs fine in Firefox, but with the function when I click my href firefox prints the word “Simple” but Firefox continues to say loading…. and never stops. Works fine in IE. What am I doing wrong?

Many many thanks!!

Marcux

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisOct 22.2007 — When you call "document.write()" after the page is loaded, the browser will issue a "document.open()" so that it can write to it because the document is closed by the finish of the load. Opening a document essentially erases its content (including your script) so the browser doesn't have any instructions to read after the first script line. Apparently IE "dies" a bit more gracefully than does FireFox.
×

Success!

Help @marcux 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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