【问题标题】:Whole page scrolls down by clicking link directed to inside link in iframe通过单击指向 iframe 中的内部链接的链接,整个页面向下滚动
【发布时间】:2013-07-04 00:03:29
【问题描述】:

我有一个导航栏,上面有一些指向 iframe 的链接。此链接包含内部链接。

$("#pr1").click(function(){
    $("#content").html('<iframe id="idIframe" src="research/index.html#pr1" frameborder="0" height="100%" width="98%"></iframe>');

如果我点击这个链接,它会将 id=pr1 放在 iframe 的源文件中。没关系。但不仅是 iframe,而且是整个页面。由于 iframe 位于页面中间,因此整个网站会向下滚动。

这在 IE、Chrome 中会发生,但在 FF 中不会。如何避免?

编辑 所以我想要什么。该站点应保持“在同一个地方”。但是 iframe 应该转到“他的”位置。

【问题讨论】:

标签: jquery html css iframe


【解决方案1】:

尝试以下方法:

$("#pr1").click(function(e){
    e.preventDefault();
    $("#content").html('<iframe id="idIframe" src="research/index.html#pr1" frameborder="0" height="100%" width="98%"></iframe>');

【讨论】:

    猜你喜欢
    • 2013-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-08
    • 1970-01-01
    • 2013-02-15
    相关资源
    最近更新 更多