[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help, please! Ack! Oop!



At 12:21 PM 1/14/96, Jeff Barnum wrote:
>Could somebody please let me know why Netscape 2.0b5 (Mac, 68k) insists on
>crashing whenever I include a "document.write" call?  Thia simple script
>crashes Netscape every time I load it.:
>--------------------------
><head><title>yeah</title></head>
><body onLoad="changebg()">
><script>
>function changebg () {
>        document.write("Hello world");
>}
></script>

I believe the problem is as follows: You're trying to do a document write
in changebg(), but by the time changebg() is called from OnLoad the
document is already all loaded and written, and can't be written to
anymore.  Hence the error (which of course should be trapped instead of
causing a crash).

Try the following code instead:

<head><title>yeah</title></head>
<body>
<script>
function changebg () {
       document.write("Hello world");
}
changebg();
</script>

I haven't tested this, but it looks more likely to work.

Frank


--
Frank Hecker          Pre-sales tech support, Netscape field sales group
hecker@netscape.com   http://home.netscape.com/people/hecker/index.html