Solved

Change window.location.href without page reload

Posted on 2009-05-04
4
5,121 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

726 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