So here is what I need to do.
I have a web app that needs to work with these kind of URLs:
http://app.com/?this_is_similar_to_anchor
By default, I can use window.location.hash and just use the # to change things on the URL. But I noticed a few websites are using a question mark instead of hash. And this is what I need.
Why do I need it?
I need to send whatever after # comes to the server, but CAN NOT send it using ajax once the page loads.
So, its vital for the app to have whatever comes after # in order to process the page.
That’s when I came to the point of using ? instead, so the server side also has access to it.
Its like client side and server side are sharing this parameter.
I tried different methods to just use:
window.location.href= 'add_parameter';
event.PreventDefault(); or return false; etc to stop the browser to actually change the URL.
TLDR: I need to be able to change the URL from this:
to this
on the fly, without reloading the page and NOT using #. (Or any way to convert the # to ?)
Thanks,
Use
pushStatewhich is what Github do, but note limited browser support.