I want to navigate from page1.html to page2.html and at the same time adding querystring in URL using javascript.
I tried:
window.location.href = 'page2.html?uname=mustafa';
It does navigate to page2.html but "?uname=mustafa" is not added in URL. So am unable to parse querystring on page2. How can I achieve it?
Have you tried using just
window.location = 'page2.html?uname=mustafa';
instead of using .href
? This should preserve the querystring.
Worked for me in Chrome and FF with .href
just fine, but I used absolute URLs:
window.location = 'http://google.com/?test=blah&foo=bar';
window.location.href = 'http://google.com/?test=blah&foo=bar';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With