开发者

Preventing scroll to top when a hash link is clicked w/ Jquery ScrollTo plugin

开发者 https://www.devze.com 2023-04-13 08:01 出处:网络
This is driving me nuts! I have content mid page that would scroll not unlike a slide show, each i开发者_JAVA百科con represents a new section of content that would refresh in the view space.

This is driving me nuts! I have content mid page that would scroll not unlike a slide show, each i开发者_JAVA百科con represents a new section of content that would refresh in the view space.

My issue is every time a hash link is clicked it, the content does refresh but I am taken to the top of the page where the content is now out of view.

I've tried what I assumed would help:

return false
preventDefault
Dummy hashes ( #_XYZ)
#null
onClick="return false"
href="javascript;void(0);"

Nothing helped. I am assuming I need to grab and set page position but being a JS beginner I am not sure how to apply it correctly.

Here is some of the code I am using:

$('#case1Step1').click(function(e)
{
      e.preventDefault();
    $('#webMain').fadeOut('normal',function(e)
    {
        $('#step1Case1').fadeIn();
    });     
    _gaq.push(['_trackEvent', 'WebThumbs', 'big']);
    return false;
}
);

Again this response is working but I look page position and end up on top of page.

0

精彩评论

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