window.location.search vs window.location.href

window.location.href
The href property sets or returns the entire URL of the current page.

window.location.search
The search property sets or returns the querystring part of a URL, including the question mark (?).

Suppose  our current page url is "http://www.example.com/p/online-html-editor?demoid=4545454545"
window.location.href is "http://www.example.com/p/online-html-editor?demoid=4545454545"
window.location.search is "?demoid=4545454545"


Demo

No comments:

Post a Comment