开发者

Horizontally scrolling a web page

I have a page that scrolls horizontally left to right. As the user completes the form, the page is scrolled to the left to show the next part of the form. This is no problem with jQuery. The problem is that I want to have the option to have the parent page jump to a specific subpage of 开发者_运维百科the form. If my code were vertical, this could be easily done with hashtags. The only other way that I can think of is to pass a GET variable in the querystring and then echo the GET variable to a javascript variable and move the page that way. Is there a better way?

var subpage = '<?php echo $_GET['subpage'] ?>';
if (subpage == 'yes') {
    $('#page_wrapper').css('left', '-2000px');
}


You can still do it with hashtags:

var subpage = window.location.hash;
if (subpage == '#yes') {
    $('#page_wrapper').css('left', '-2000px');
}

Also you probably want to use scrollLeft to set the horizontal scroll of the page, if you do it the way you're doing it there you'll run some of the page outside of the viewport.

$(document.body).scrollLeft(2000);


You can jQuery plugin to move to any part of the webpage using scrollTo. Hope it will work for you. http://flesler.blogspot.com/2007/10/jqueryscrollto.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜