javascriptreplace

Removing ? from document.location.search


How can I place document.location.search into a variable w/o the '?' Is there a simple regex, or can I just ignore the first character?


Solution

  • No problem

    window.location.search.substr(1);
    

    Edit

    I didn't even think about it 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