window.scrollTo在Internet Explorer 11中不起作用 [英] window.scrollTo is not working in Internet Explorer 11
本文介绍了window.scrollTo在Internet Explorer 11中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望在启动页面时默认将滚动条放在顶部.但是下面的代码在chrome中可以正常工作,但在IE11中不能正常工作.
I want the scrollbar to be positioned on top by default as soon as I launch the page.But the below code works fine in chrome but not in IE11.
如果我尝试调试脚本,则滚动条位于顶部.
If I try to debug the script, the scrollbar is positioned on top.
$(document).ready(function () {
window.scrollTo(0,0);
}
我在线尝试了其他解决方案,例如
I tried different solution online such as
$(window).scroll().scrollTop(0);
document.body.scrollTop(0);
但是在IE中没有任何作用.请帮助我
But nothing worked in IE.Kindly help me
推荐答案
尝试使用$('body,html').scroll().scrollTop(0);
try using $('body,html').scroll().scrollTop(0);
或$('body,html').animate({scrollTop:0});
or $('body,html').animate({scrollTop:0});
这篇关于window.scrollTo在Internet Explorer 11中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文