问题仅存在于FireFox上(从3.6到现在9),其他浏览器都可以.我的代码看起来像这样:
jQuery.extend({
AnchorFromUrl : function(url) {
var anchor = url.substr(1).replace('.html','');
$.fizzer_anchor = anchor;
window.location.hash = anchor;
return anchor;
}
});
Run Code Online (Sandbox Code Playgroud)
最奇怪的是,如果我在window.location.hash = anchor之前发出警报; 单击"确定"按钮后,行不会消失,删除该警报()并使您的图标消失.
注意:如果您这样做,它也会丢弃图标window.location = something.