PDA

View Full Version : 2 questions on delaying jscript load


shoofy
10-09-2004, 10:08 PM
I have two questions:
1) Is there a way to test to see if a script has loaded yet (this is an external script, not an internal function)?
2) Can I use this to delay loading global variables in a different script.

I need this because I have a script that loads an RSS news feed, which defines the height of the page, but it takes a few seconds to load depending on connection speed and browser/browser settings. I have another script with a global variable that gets the height of the page. The problem is that even though the second script is at the very end of the body and the function referencing the global variables begins onLoad, it seems that the variables are loaded right away so the height is set to zero, instead of whatever it's supposed to be. I tried putting a long delay on calling the function using setTimeout, but it didn't change the global variables. I assume there must be some reason why this is happening and/or a way to fix it, but I can't figure out what it is :( .

coothead
10-10-2004, 08:37 AM
Hi there shoofy,

this is, I presume, to do with this thread (http://www.htmlforums.com/showthread.php?s=&threadid=46982) :supereek:

Well, I have found a way to impliment offsetHeight into the coding :D

You may check out the fruit of my endeavours by... clicking here :cool: (http://achelous.mysite.wanadoo-members.co.uk/iframe_scroll/iframe3.html)

shoofy
10-10-2004, 02:27 PM
Good call coothead :D . What happened to not writing any more scrolling iframes ever? This version works great! I actually got rid of the start div and just called findHeight() onload, but it still works. This now does well enough for me to actually integrate into my site. I do have a few other things that I want to try to work on myself before you tell me either how to do it or that they're not possible to do.

1) make it slow down instead of stop onmouseover. It seems like you should just be able to send the variable 'speed' to the function instead of having it be global, but I'm running into trouble with scroller=setTimeout("divScroll(speed)",speed); which just stops the code alltogether.

2) Use buttons outside of the iframe to make it: stop, restart, scroll up, and scroll down. Two of these three functions already exist, and I'm sure I could just adjust divScroll() to go the opposite direction, but I'm not sure if there's a way to call these functions from outside the iframe.

Jondalar
10-10-2004, 03:24 PM
Originally posted by shoofy
1) make it slow down instead of stop onmouseover. It seems like you should just be able to send the variable 'speed' to the function instead of having it be global, but I'm running into trouble with scroller=setTimeout("divScroll(speed)",speed); which just stops the code alltogether.
Does this work?
scroller=setTimeout("divScroll("+speed+")",speed);

Originally posted by shoofy
2) Use buttons outside of the iframe to make it: stop, restart, scroll up, and scroll down. Two of these three functions already exist, and I'm sure I could just adjust divScroll() to go the opposite direction, but I'm not sure if there's a way to call these functions from outside the iframe.
You should be able to call functions from the parent document using
window.frames["frame name"].function name();

shoofy
10-10-2004, 03:30 PM
Does this work?

scroller=setTimeout("divScroll("+speed+")",speed);

Yes it does. I can't believe I didn't notice that before!!!:o

As for your other point, instead of frame name, would I use the name of the iframe tag? I tried that and it didn't work.

coothead
10-10-2004, 04:15 PM
Hi there shoofy,
What happened to not writing any more scrolling iframes ever?
My addiction got the better of me. :o
So I had to try and refine my original rubbish
into something with a little more class :cool:

Can't think why you don't want it to stop on mouseover :confused:
Do you want your viewers to chase the links with the cursor :supereek:

Surely to have extra controls will make the whole thing unduly complicated for the the user }:-)

Of course, I may be just pushing my own work :)

Latest modification here :cool: (http://achelous.mysite.wanadoo-members.co.uk/iframe_scroll/iframe3.html)