iframe on the page bottom: avoid automatic scroll

2019-02-02 13:25发布

I have an iframe from the middle to bottom on a page. When I load the page it scrolls to the bottom. I tried to body onload window.scroll(0,0) but it does an ugly effect because it first goes down and then immediately scrolls up.

What's the cause of this automatic scroll to bottom with iframe on the page?

7条回答
老娘就宠你
2楼-- · 2019-02-02 14:06

Similar method but using classes.. I added a class to the iFrame's parent div of "iframe_display" with a style inside that of visibility: hidden. On page load I then used jQuery to remove the class

.iframe_display{visibility:hidden}

$(function(){
    $('#iframe_wrapper').removeClass('iframe_display');
});

This takes the focus away from the iFrame and stops the scrolling down to the iFrame on page load

查看更多
登录 后发表回答