删除?来自document.location.search

9 javascript replace

如何将document.location.search放入一个没有"?"的变量中 有一个简单的正则表达式,还是我可以忽略第一个字符?

Pet*_*ley 17

没问题

window.location.search.substr(1);
Run Code Online (Sandbox Code Playgroud)

编辑

我第一次没想到它,但你应该引用window.location,而不是document.location.它拥有最广泛的浏览器支持.

https://developer.mozilla.org/En/Document.location#Notes