Solved

Change window.location.href without page reload

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A procedure for exporting installed hotfix details of remote computers using powershell
Owning a franchise can be the dream of a lifetime. It provides a chance for economic growth. You can be as successful as you want.  To make your franchise successful, you need to market it successfully. Here are six of the best marketing strategies …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now