滚动内嵌框架
我有两个窗口:一个是要位于 iframe 中的页面,另一个是要容纳 iframe 的页面。我的项目的目标是制作一个滚动的 iframe,但是当鼠标悬停在其上时,它会暂停。我目前在 iframe 中的页面有以下代码: http://dabbler.org/edit/asdf/scrolling/index.html 以及用于容纳 iframe 的页面代码: http://dabbler.org/edit/asdf/scrolling/index2.html
我的代码有什么问题吗? (是的,我知道我没有 body、head、HTML 和其他内容,这不是问题,因为这些内容是在解释页面时自动插入的)
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, but, 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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
window.onmouseover 和 window.onmouseout 未正确定义。
您有这样的情况:
您想要这样做:
您将 onmouseout 和 onmouseover 设置为调用 pageScroll 和 unpageScroll 的返回值,但您想将 onmouseout/onmouseover 设置为 pageScroll 和 unpageScroll 函数。
最后,您在
setTimeout
中调用了错误的函数。您正在调用 pageScroll,但您希望调用
pageScroller
,它会执行实际的滚动。编辑
顺便说一句,当页面尽可能垂直滚动时,您应该在将来的某个时刻处理在 pageScroller 中调用clearTimeout。如果窗口已经尽可能滚动,那么继续调用scrollBy是没有意义的。
The window.onmouseover and window.onmouseout are not defined correctly.
You have this:
You want to do this:
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
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.