0

Is it possible to modify the below code so that it scrolls only to a particular position in Safari and not to the bottom as it does now.

javascript:scroll(0,document.getElementsByTagName(%20′body’)%5B0%5D.scrollHeight);

I'm okay if you can suggest a completely different code as well for the same.

Thanks in advance!

4

1 回答 1

0

您可以使用 scrollTo(h,v) 滚动到页面上的某个位置

//h = horizontal, v=vertical
window.scrollTo(0,500); 

http://jsfiddle.net/vLmb9/

编辑:在 iPhone 部分隔开。您必须使用 setTimeout:

setTimeout(function () {
  window.scrollTo(0, 500);
}, 1000);
于 2013-08-20T07:34:40.970 回答