admin管理员组文章数量:1418073
I have a function that I call on the onclick event of a button.
function ScrollToEditor() {
$('html, body').animate({
scrollTop: $("#ckeditor_editor").offset().top
}, 1000);
}
<button id="btnScrollToBottom" class="button right" onclick="ScrollToEditor();" type="button">Scroll</button>
This works in Chrome, Firefox and IE11. However, it does nothing in Edge. There are no console errors and the I have made sure that the function is definitely being called.
Any help here would be appreciated.
I have a function that I call on the onclick event of a button.
function ScrollToEditor() {
$('html, body').animate({
scrollTop: $("#ckeditor_editor").offset().top
}, 1000);
}
<button id="btnScrollToBottom" class="button right" onclick="ScrollToEditor();" type="button">Scroll</button>
This works in Chrome, Firefox and IE11. However, it does nothing in Edge. There are no console errors and the I have made sure that the function is definitely being called.
Any help here would be appreciated.
Share Improve this question edited Nov 22, 2017 at 15:38 Rory McCrossan 338k41 gold badges320 silver badges351 bronze badges asked Nov 22, 2017 at 15:36 SmithySmithy 79110 silver badges30 bronze badges3 Answers
Reset to default 2For anyone who may e across this issue as well, the only thing that worked for me was the following function:
function ScrollToEditor() {
document.getElementById('ckeditor_editor').scrollIntoView();
}
Use pageYOffset instead of scrollTop
Note: pageYOffset is not supported supported below IE 9
I may be late but I had the same problem. I found the solution in the following code:
function topFunction() {
document.body.scrollTop = 0; //Zero is the pixels from the top of the screen
document.documentElement.scrollTop = 0;
}
This worked fine for me. I had the problem with Edge. I hope this will be useful for someone with the same problem.
本文标签: javascriptScrollTop function wont work in EdgeStack Overflow
版权声明:本文标题:javascript - ScrollTop function wont work in Edge - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745280930a2651420.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论