滚动到页面加载之前
我正在尝试使用javascript使页面加载200px。但我总是看到前面的1秒向前滚动。
I'm trying to make the page load 200px further down using javascript. But I always see 1 second of the top before is scrolls down.
vimoe这样做,尝试在页面加载后向上滚动, http://vimeo.com/49645156
vimoe does this, try scrolling up after the page is loaded, http://vimeo.com/49645156
margin-top:-200px .. Gives我这个效果,但我不能在保证金设置为负数后向上滚动。
margin-top:-200px.. Gives me this effect, but I cant' scroll up after margin is set with a negative number.
也许在页面出现之后制作一个改变身体边距的jquery解决方案加载,会有效吗?
Maybe make a jquery solution that changes the body margin-top after the page is loaded, will that work?
目前使用此脚本
function jumpScroll() {
window.scroll(0,200); // horizontal and vertical scroll targets
}
我只是调用这个脚本来自身体的onload。
I just call this script from the body with onload.
为什么不使用分部ID而不是给予边距?
Instead of giving margins, why don't use the division id?
我相信你已经给你想要在加载时显示在上面的部门提供了一个ID。
I am sure you have given a ID to the division which you want to show on top when loading.
只需使用div ID,如下所示:
just use the div ID, like this :
$(document).ready(function (){
var div= $('#example'); // take your div id
$(window).scrollTop(div.offset().top).scrollLeft(div.offset().left);
}