2014-11-14 20 views
0

我有以下字符串:编辑window.location.hash将导致查询字符串被删除

http://example.com/?phrase=samplePhrase 

,当我点击某一个元素的URL接收这样的散列编辑:

#show/item 

利用这段JavaScript代码:

window.location.hash = "/" + "show" + "/" + "item"; 

但我想这只是哈希编辑追加到任何CUR租网址是。所以有:

http://example.com/?phrase=samplePhrase#show/item 

但它首先删除查询字符串是什么都然后使URL是这样的:

http://example.com/#/show/item 

谁能帮助吗?

回答

1

如果你需要得到PARAMS出来的URL,你应该能够做这样的事情:

var params = window.location.search; 
window.location.hash = params + "#" + "show" + "/" + "item";