开发者

javascript top.location.hash = ""; without browser jumping to top?

开发者 https://www.devze.com 2023-02-18 23:51 出处:网络
top.location.has开发者_StackOverflowh = \"\"; adds a # to my addressbar. As soon as top.location.hash = \"\"; is called and a # is added my browser window jumps to its top.
top.location.has开发者_StackOverflowh = "";

adds a # to my addressbar. As soon as top.location.hash = ""; is called and a # is added my browser window jumps to its top.

Is there any chance a could prevent that?

$('#element').live('click', function() {
        top.location.hash = "map";
    });


Just change the hash to something that is not significant and never used, e.g. an underscore. AFAIK, changing the hash to nothing will always scroll the page to the top.

0

精彩评论

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