Closed Thread Icon

Topic awaiting preservation: javascript error (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=8145" title="Pages that link to Topic awaiting preservation: javascript error (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: javascript error <span class="small">(Page 1 of 1)</span>\

 
silence
Maniac (V) Inmate

From: soon to be "the land down under"
Insane since: Jan 2001

posted posted 04-16-2002 04:21

Hey guys, I keep getting an error on a page and I need some help diagnosing.

The page is at http://www.blueskynet.as/index2.shtml

Now, if I change the script, I don't get the error but the script doesn't work. Any suggestions?



[This message has been edited by silence (edited 04-16-2002).]

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 04-16-2002 05:42

I didn't get any errors. What browser, what line, what error message, and what's the script supposed to do? =)

silence
Maniac (V) Inmate

From: soon to be "the land down under"
Insane since: Jan 2001

posted posted 04-16-2002 06:46

Okay, I'm using IE 5.0 and script debugging has to be enabled in the advanced settings. I haven't put in NN support yet until after I get the bugs out of IE.

I'm getting a 'document.all.floater.style' is not an object error.

The error appears because of this line:
floating = document.all.floater.style;

Now, I'm trying to get the page menu, which is in a div, to move as the page is scrolled down. So I change top to the page offset in this next line:

floating.top = parseInt(document.body.scrollTop);

The reason I set the floating variable, is so I can set it accordingly for NN and IE.

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 04-16-2002 07:03

The error appears because you try to access "floater" layer before the page has finished loading. You should call setInterval() function after page finishes loading, like this:

window.onload = function() { setInterval("float_func('floating_div')",10); }


Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 04-16-2002 07:06

Oh, I see the problem.

What you're doing is you're waiting ten milliseconds (setInterval("float_func()",10) , and then assigning "floating = document.all.floater.style;". The problem is, if the page hasn't finished loading after those ten milliseconds, that causes an error, because you're not allowed to access HTML elements until they've been created. If that part of the HTML page hasn't loaded when the function is called, then it will try to get to document.all.floater.style before it knows document.all.floater exists.

The solution? Delete the line

setInterval("float_func()",10);

and add

onload="float_func()"

in the body tag. That will keep the function from running until the whole page has loaded.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 04-16-2002 07:07

It appears that mr. max and i are in agreement about the problem. choose your favorite solution. =)

silence
Maniac (V) Inmate

From: soon to be "the land down under"
Insane since: Jan 2001

posted posted 04-16-2002 08:02

Ahh. hehe. Thanks alot guys, I understand now.

:edit:
Well, even after changing it to the onload event, I still got the error. So, I finally put the code after the floating div. That way the div should load before the function runs. Thanks again for clearing up a bit more about how jscripts are run for me.
:edit:



[This message has been edited by silence (edited 04-16-2002).]

« BackwardsOnwards »

Show Forum Drop Down Menu