开发者

jQuery, when performing AJAX loads, how to prevent the site from scroll down & staying put

I'm building a web app that loads content with $.ajax and then injects the cont开发者_StackOverflow社区ent in a contentCol...

problem is every time this happens it scroll the browser down. Is there a global way to prevent this and just keep the scrollbar where the user was initially before calling the AJAX?

Thx


ok here's what worked... Not loving this bec it prevent the user from REFRESHing ajax content. I'd love it if you can one up me with something better and more elegant...

$('a').live('click', function() {
    // Page Jump Prevention - Does the clicked on Hash differ from the currently loaded hash, if not return false
    if (window.location.hash.split('#')[1] == this.href.split('#')[1]) {
        //alert('Dude we already loaded this!')
        return false;
    }
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜