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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745280930a4620275.html
评论列表(0条)