Reputation: 3430
Currently I am using this code to give a user access by its uuid
to a private page.
if (!!$.cookie('my_uuid_cookie')) {
var my_uuid = $.cookie("my_uuid_cookie")
var target = window.location.href + '?uuid=' + my_uuid;
window.location.href = target;
}
First I check if the url does not contain any uuid
. If not, I fire the code above.
This being said you may notice, that window.location.href
forces a page reload, which does not look to good. Is there a way to "silently" add the query string to my url?
(The URL is not being necessary on page load, the user has to toggle another function by clicking on it. Thats the moment, when the query string is needed.)
Upvotes: 0
Views: 50
Reputation: 1379
Try this :
window.history.pushState("object or string", "Title", "/new-url");
Note that will work only on HTML5 browsers
https://developer.mozilla.org/en-US/docs/Web/API/History_API#The_pushState()_method
Upvotes: 1