/    Sign up×
Community /Pin to ProfileBookmark

Window won’t stop loading after document.write

Hiya

I’m making my first forays into Javascript – the following code just writes some example code to a page.

The problem is that after the data has been written to the page, the “Loading” whirligig is still whirring around (Netscape 7). I would expect it to stop, or say “Done”, or something.

Presumably I’m doing something fundamentally wrong – but what?

[CODE]
<html>
<head>
<title> Java Script won’t stop loading example</title>

<meta name=”generator” content=”Namo WebEditor v6.0(Trial)”>
<script type=”text/javascript”>

function MyFunc(f){

document.open(“text/html”);
document.writeln(‘<html>’);
document.writeln(‘<head>’);
document.writeln(‘<title>JavaScript Page</title>’);

document.writeln(‘</head>’);
document.writeln(‘<body>’);

// loop through the array
for(var n=0;n <= 5;n++){
document.writeln(‘Line Number ‘ + (n) + ‘<br>’);
} //next

document.writeln(‘End of page’);

document.writeln(‘</body>’);
document.writeln(‘</HTML>’);
document.close;
} //end of function

</script>

</head>
<body>
<input type=”button” value=”Muttley! Do something!” onclick=”MyFunc(this.form);”>
</form>
<p>&nbsp;</p>
</body>
</html>
[/CODE]

TIA

Joolz

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@PittimannJul 02.2004 — Hi!

Try document.close(); instead of document.close;

Cheers - Pit
Copy linkTweet thisAlerts:
@jz_007authorJul 05.2004 — Oh, the intricacies of a new language...

Thanks!

Joolz
Copy linkTweet thisAlerts:
@PittimannJul 05.2004 — Hi!

You're welcome!

Cheers - Pit
×

Success!

Help @jz_007 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.4,
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,
)...