Solved

Change window.location.href without page reload

Posted on 2009-05-04
4
5,075 Views
Last Modified: 2012-05-06
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
0
Comment
Question by:vbhargav80
  • 2
4 Comments
 
LVL 13

Expert Comment

by:usachrisk1983
ID: 24301192
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?
0
 
LVL 13

Expert Comment

by:usachrisk1983
ID: 24301193
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.
0
 

Author Comment

by:vbhargav80
ID: 24301481
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.
0
 
LVL 42

Accepted Solution

by:
David S. earned 125 total points
ID: 24301648
Changing window.location.hash, e.g. "#make=123", doesn't reload the page, but you can only change it for the current page.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Giving access to ESXi shell console is always an issue for IT departments to other Teams, or Projects. We need to find a way so that teams can use ESXTOP for their POCs, or tests without giving them the access to ESXi host shell console with a root …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question