window.scrollTo无法在手机中使用 [英] window.scrollTo is not working in mobile phones

查看:112
本文介绍了window.scrollTo无法在手机中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网页移动视图中,我可以在垂直和水平方向上滚动,但这始终位于左上角。
现在我想用window.scrollTo或类似的东西将视口设置为我的自定义位置。 window.scroll似乎只适用于桌面浏览器。

on my mobile view of my webpage i can scroll in vertical and horizontal direction, but this starts always at the top left corner. Now i want to set the viewport to my custom position with window.scrollTo or something equivalent. window.scroll seem just to work for desktop browser.

我知道如何解决这个问题吗?

any idea how i could solve that?

推荐答案

我终于工作了。

我不得不另外使用setTimeout函数

i had to use additionally the setTimeout function

setTimeout(window.scrollTo(x,y),100);

这篇关于window.scrollTo无法在手机中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆