【问题标题】:How to set scroll position of WebPage Containing Iframe at top when that page is open当该页面打开时,如何在顶部设置包含 iframe 的网页的滚动位置
【发布时间】:2013-08-03 12:18:39
【问题描述】:

我们有一个包含 iframe 的 ASPX 页面。 iframe 用于存储页面内容。 我们的问题是假设我们在一个带有滚动条的页面上有一个数据(可编辑行)。如果我们单击页面行的上部,则新页面正确打开,即它是打开的并且滚动条位置在顶部。 但是当我们单击下部行时,我们打开的页面在底部有滚动位置。 我们怎样才能使滚动位置到顶部? 到现在我们都试过了,

window.onload = function () {
$('html').scrollTop(0);

&

 var myIframe = parent.document.getElementById("Content");
            myIframe.onload = function () {
                myIframe.contentWindow.scrollTo(0, 0);
            };

&

document.body.scrollTop = document.documentElement.scrollTop = 0;

但没有运气。请帮忙。

【问题讨论】:

    标签: javascript jquery jquery-plugins jquery-events


    【解决方案1】:

    此代码对我有用..

     $(document).ready(function () {
    
                var Ifr = parent.document.getElementById("Content");
    
                Ifr.onload = function () {
    
                    parent.scrollTo(0, 0);
                };
    
    }); 
    

    【讨论】:

      猜你喜欢
      • 2014-10-30
      • 2012-10-30
      • 1970-01-01
      • 1970-01-01
      • 2016-07-09
      • 1970-01-01
      • 2015-06-11
      • 2011-04-09
      • 2017-12-02
      相关资源
      最近更新 更多