vbhargav80
asked on
Change window.location.href without page reload
Dear Experts,
I am trying to do something like this:
window.location.href = newUrl
But this causes the page to refresh. How can i do it without refreshing the page. All i want is when i click a button on the page, it modifies the address bar and does not refresh the page
I am trying to do something like this:
window.location.href = newUrl
But this causes the page to refresh. How can i do it without refreshing the page. All i want is when i click a button on the page, it modifies the address bar and does not refresh the page
This cannot be done due to browser security. Imagine if you could change the address bar without directing the user to the page, how many new phishing sites would go up if suddenly you could make your page have some other sites (say your banks) address in the URL?
Follow-up: What's the end result you're looking for? The only thing that comes to mind is that you want to trick the user into thinking their somewhere else. If this isn't the case, there may be a more allowable way to do what you're looking to get done. For example, if you just don't want the user to see all the URL variables, they could be redirected to POST variables.
ASKER
Hi usachrisk1983,
Here is what I am trying to do:
I have a search page which is AJAXed. When the user selects values from the dropdown, it appends #make=123 etc to the url. I do a search and my browser cache will store "http://myurl/#make=123" for the javascript history.
On my search result page when I click the browser back button, I do not want the '#make=123" in my address bar due to various reasons. Just wondering how I can get rid of this #make=123 stuff.
Here is what I am trying to do:
I have a search page which is AJAXed. When the user selects values from the dropdown, it appends #make=123 etc to the url. I do a search and my browser cache will store "http://myurl/#make=123" for the javascript history.
On my search result page when I click the browser back button, I do not want the '#make=123" in my address bar due to various reasons. Just wondering how I can get rid of this #make=123 stuff.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.