Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Change window.location.href without page reload

Posted on 2009-05-04
4
Medium Priority
?
5,239 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 43

Accepted Solution

by:
David S. earned 500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Working from home is a dream for many people who aren’t happy about getting up early, going to the office, and spending long hours at work. There are lots of benefits of remote work for employees.
This week I attended a Startup Week Chattanooga talk on Gender Diversity in Technology. Check out what I learned.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

609 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