Javascript iframe可自动滚动到底部

Javascript iframe可自动滚动到底部,javascript,scrollbar,Javascript,Scrollbar,我不能让这段代码工作,当iframe刷新时,iframe应该自动向下滚动到底部 代码: iframe: $(窗口)。加载(函数() { var$contents=$('#frame').contents(); $contents.scrollTop($contents.height()); }); ​ cn有人帮我吗,我有点困了你有权访问iframe中的代码吗?我相信您需要在iframe代码本身中设置scrollTop 例如: $("body").scrollTop(100); 编辑:在

我不能让这段代码工作,当iframe刷新时,iframe应该自动向下滚动到底部

代码:


iframe:

$(窗口)。加载(函数() { var$contents=$('#frame').contents(); $contents.scrollTop($contents.height()); }); ​

cn有人帮我吗,我有点困了

你有权访问iframe中的代码吗?我相信您需要在iframe代码本身中设置scrollTop

例如:

$("body").scrollTop(100);

编辑:在此处查找更多信息:

要截获的onLoad事件应该是来自iframe本身的事件,而不是来自窗口的事件

此外,Blender的评论部分有效

仅当在iframe上打开的文档与父文档属于同一域时,此设置才会起作用。使用相同的协议:

- http://domain/main.aspx as the container and http://domain/inner.aspx at the iframe is valid
- http://domain/main.aspx as the container and https://domain/inner.aspx at the iframe will be blocked
- http://domain/main.aspx as the container and http://another/inner.aspx at the frame will also be blocked

(从我的PDA发送)

你的小提琴说它应该使用MooTools。但是您的代码调用jQuery。小提琴上的设置是否错误?无法修改帧:不安全的JavaScript试图从带URL的帧访问带URL的帧。域、协议和端口必须匹配。我在桌面上尝试了它,但仍然没有向下滚动,即使它是一个安全的url
- http://domain/main.aspx as the container and http://domain/inner.aspx at the iframe is valid
- http://domain/main.aspx as the container and https://domain/inner.aspx at the iframe will be blocked
- http://domain/main.aspx as the container and http://another/inner.aspx at the frame will also be blocked