Solved

Change window.location.href without page reload

Posted on 2009-05-04
4
5,095 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

While it may be true that the internet is a place of possibilities, it is also a hostile environment lurking with many dangers. By clicking on the wrong link, trusting the wrong person or using a weak password, you are virtually inviting hackers to …
We have put together a white paper that aims to explain how MSPs can both improve their offering and ease the pain of after-hours service by: -Suggesting changes to workflow -Indicating how to rework policy to suit your team -Providing ConnectW…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

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