开发者

Scrolling Iframe

I have two windows: One is a page meant to be in an iframe, and one is the page meant to house the iframe. The objective of my project is to make an iframe that scrolls, b开发者_运维百科ut, when it is moused over, it pauses. I currently have the following code for the page meant to be in an iframe: http://dabbler.org/edit/asdf/scrolling/index.html and the code for the page meant to house the iframe: http://dabbler.org/edit/asdf/scrolling/index2.html

What is wrong with my code? (Yes, I know I don't have body, head, HTML and the others, that isn't the problem, for those are thrust in automatically when the page is interpreted)


The window.onmouseover and window.onmouseout are not defined correctly.

You have this:

 window.onmouseout = pageScroll();     
 window.onmouseover = unpageScroll();

You want to do this:

 window.onmouseout = pageScroll;     
 window.onmouseover = unpageScroll;

You were setting onmouseout, and onmouseover to the return values of calling pageScroll and unpageScroll, but you wanted to set onmouseout/onmouseover the functions pageScroll and unpageScroll.

And finally, you're calling the wrong function in your setTimeout.

You are calling pageScroll, but you want to be calling pageScroller, which does the actual scrolling.

EDIT

 function pageScroll(){
            num = 150;
            clearTimeout(scrolldelay);
            pageScroller();
 }
  function unpageScroll(){num = 15000000;}
  function pageScroller() {
    window.scrollBy(0,50); // horizontal and vertical scroll increments
    scrolldelay = setTimeout('pageScroller()',num); // scrolls every 100 millisecond
  }
  var num = 50;
  window.onmouseout = pageScroll;
  window.onmouseover = unpageScroll;

BTW, you should handle calling clearTimeout in pageScroller at some point in the future when the page is scrolled vertically as much as possible. There's no point in continuing to call scrollBy if the window is already scrolled as much as possible.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜