2012-05-10 27 views
1

我正在使用url中的location.hash,因为我需要在网址末尾添加一些额外的数据(如...com/page#something)。
但在此之后,我移动到其他网页,不应该在网址中散列,并以某种方式在该网址中散列apper(home.com#hash)。
这种情况只发生在Chrome中,Firefox很好。 我不想在每个页面上加载清除散列,如果有的话。 我曾尝试与此:如何清除铬中的网址中的哈希值

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "noHash", "window.location.hash = ' ';", true); 

但这叶“#”在仅适用于Chrome的网址结束。 任何想法如何删除此?

回答

2

试试这个

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "noHash", "if (window.location.indexOf('#')>-1) window.location = window.location.hash.split('#')[0];", true); 
+0

我把这个页面加载但不知何故,我们做无限循环。 – 1110

+0

@ 1110现在试试... –

+0

这段代码没有任何反应:( – 1110

相关问题