[英]javascript window.scrollto issue on Ipad
I have a javascript that includes following line of code: 我有一个包含以下代码行的JavaScript:
window.scrollto(x,y);
where x and y are the coordinates of the position where there should be scrolled. 其中x和y是应滚动位置的坐标。
This works fine on desktop computers but if I try it on an Ipad it does not scroll properly. 这在台式机上可以正常工作,但是如果我在Ipad上尝试,则无法正常滚动。
If I put an alert() statement before the window.scroll command it srolls properly. 如果我在window.scroll命令之前放置了alert()语句,则它可以正确滚动。 Does anyone know of a fix?
有人知道解决办法吗? Btw the ipad uses ios7.
顺便说一句,ipad使用ios7。
Thanks 谢谢
do this: 做这个:
window.setTimeout(function() {window.scrollTo(x,y);}, 0);
window.setTimeout(function(){window.scrollTo(x,y);},0);
also be aware of the case, scrollto is different to scrollTo in javascript. 还要注意这种情况,scrollto与javascript中的scrollTo不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.