私のウェブページのモバイルビューでは、縦方向と横方向にスクロールできますが、これは常に左上隅から始まります。ここで、window.scrollTo または同等のものを使用して、ビューポートをカスタム位置に設定したいと考えています。window.scroll は、デスクトップ ブラウザーで動作するようです。
どうすればそれを解決できますか?
私のウェブページのモバイルビューでは、縦方向と横方向にスクロールできますが、これは常に左上隅から始まります。ここで、window.scrollTo または同等のものを使用して、ビューポートをカスタム位置に設定したいと考えています。window.scroll は、デスクトップ ブラウザーで動作するようです。
どうすればそれを解決できますか?
私はついにそれを働かせました。
さらにsetTimeout関数を使用する必要がありました
setTimeout(window.scrollTo(x,y),100);
As I said in my comment, this works if your content is large enough. This means larger than the viewport. Without knowing specifics, did you look into setting the viewport meta tag?
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Now, if your content div or image or whatever exceeds the size of the viewport width (320 dips on iPhone) you can scroll on the x axis. The same is true for the y axis with different values though.