Removal? from document .location.search

How to place a .location.search document in a variable without '?' Is there a simple regex, or can I just ignore the first character?

+5
source share
2 answers

No problems

window.location.search.substr(1);

Edit

I did not even think about this for the first time, but you should refer to window.location, not document.location. It has the broadest browser support.

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

+14
source

Can you just replace the character ?? character with an empty string:

var searchWithoutQuestionMark = document.location.search.replace('?', '');

Steve

0
source

All Articles