Forum Moderators: open

Message Too Old, No Replies

setTimeout and clearTimeout using with onMouseOver and onMouseOut

         

piggybank1974

10:13 pm on Jan 26, 2003 (gmt 0)

10+ Year Member



hi there it's my first post so here goes.

<HTML>

<HEAD>
<TITLE>FRAMES</TITLE>
<SCRIPT language=Javascript>
var tims = Null;
</script>

</HEAD>

<BODY BGCOLOR="000000" BORDER="0">
<DIV HALIGN="center">
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR>
<TD WIDTH="100%">
<IMG BORDER="0" SRC="scroll_up.gif" WIDTH="16" HEIGHT="32"></TD>
</TR>

<TR>
<TD WIDTH="100%">
<IMG BORDER="0" SRC="scroll.gif" WIDTH="16" HEIGHT="28"></TD>
</TR>
<!-- "javascript:parent.MainFrame.scrollBy(0,100)" -->
<!-- onMouseOut="clearTimeout(window.top.timer);" -->
<!-- onMouseOver="window.top.timer=window.top.setTimeout(javascript:parent.MainFrame.scrollBy(0,100), 200);" -->
<TR>
<TD WIDTH="100%">
<IMG BORDER="0" SRC="scroll_down.gif" WIDTH="16" HEIGHT="33" onMouseOver="window.top.tims=setTimeout('parent.MainFrame.scrollBy(0,100)', 2);"></TD>
</TR>

</TABLE>
</DIV>
</BODY>

well from the above code i'm trying to scroll one of my pages by just moving over an image, but i want it to continue scrolling when i'm there so i thought lets use SetTimeOut and when i move from the image lets use ClearTimeOut but it gives me errors can anybody help me to fix it.

it still works when i move the mouse from the image back again just not when i leave it there.

I sore something like this on EA's web site in battlefield 1942. So i'm trying to do that well a version anyways.

i've taken out ClearTimeOut for the moment.
thanks the pig

DrDoc

1:06 am on Jan 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



don't use setTimeout, use setInterval instead ;)

piggybank1974

9:29 am on Jan 27, 2003 (gmt 0)

10+ Year Member



hi DrDoc thanks for you reply.

I will change it to setInterval when I get home from college

setTimeout('parent.MainFrame.scrollBy(0,100)', 2);"

Am I calling SetTimeout correct?

and defining the Variable to hold the ID for setTimeout/setInterval?

The code 'parent.MainFrame.scrollBy(0,100)' in setTimeout is this how i call it as this give me an error also?

thanks the pig

DrDoc

6:29 pm on Jan 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



First of all, let me apologize for not welcoming you to Webmaster World! :(
So, welcome! ;)

Now, you don't have to define the variable tims (

var tims = Null;
). Besides, if you want to do that the correct syntax is
var tims = null;
with
null
lowercase.

Second, you can change the onmouseover to this:

onmouseover="tims=setInterval('parent.MainFrame.scrollBy(0,100)', 10);"

and the onmouseout to:
onmouseout="clearInterval(tims);"

That should work.

piggybank1974

7:50 pm on Jan 27, 2003 (gmt 0)

10+ Year Member



Hi DrDoc

Thanks for you reply again. I was wondering if anybody would say hello first timer. ooo it's good to be young again!

anyways thanks again know dought i will be back again

the pig

piggybank1974

7:55 pm on Jan 27, 2003 (gmt 0)

10+ Year Member



Thanks DrDoc

It works, I think its a good effect don't you?

The very happy PIG

DrDoc

8:02 pm on Jan 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You're welcome :)

Good effect? Yes, it's very "nifty" ..

However, nifty things like these will not work if the user is using keyboard only to surf your page. Nor will it be useful to those with disabilities that have to rely on screen readers, head wands, and other tools to surf the Internet.

Anyway, still a nice effect.