[Javascript] Why does writeln clear the whole page?
spacific at paradise.net.nz
spacific at paradise.net.nz
Fri Jan 4 21:13:16 CST 2002
Hi,
I am trying to use a document.writeln under certain conditions. But it always causes the whole page to be cleared.
For example, this demonstrates the problem.
<html>
<head> <title>WRITELN</title>
<SCRIPT LANGUAGE="JavaScript"> <!--
function DoThis()
{
document.myForm.myButton.blur();
document.write('<h1>What happened to the page?</h1>')
}
//--> </SCRIPT>
</head>
<body>
<br>
<form name="myForm">
<input type="button" name="myButton" value="Click Here"
onClick="JavaScript:DoThis()">
<br>
</form>
<br><br>Some text.<br>
</body>
</html>
I thought perhaps anything with focus got replaced by the writeln call, hence the attempt to unfocus (blur) the button -- but to no avail. I have also tried to place the JS in the body, but with no change. Writeln is documented in lots of resources but I cannot find anything about it clearing the page. I presume I'm missing something (probably obvious!).
Thanks,
John
More information about the Javascript
mailing list