Jump to content

Changing the URL address bar without reloading the page.


Recommended Posts

Is it possible that to change the address to something else with out reloading the page? I understand that if it were possible it could make a real security issue (Phishing and so on). but I need it just to change the value of some GET variable , in case some of the user want to share this page on facebook or send the perticiler page to someone. ( all the website is just one page and it's using AJAX ) There is the website in case you didn't got the point:

 

http://maadif.co.cc/stuff/

 

!-! currently I use \/ but it does refresh the page.

 

window.location.href = "http://maadif.co.cc/stuff/?id=" +question_id;

 

No, you can't change it without redirecting the user.

 

Most of it, that is. You can use fragments (the stuff after the # in the URL) instead: you can change those all you want without reloading the page. Like somebody (I forget who) has URLs like

http://www.example.com/#!/do/something/cool

The downside is that you need a fair bit of JavaScript to support it, as somebody might go there directly without going through your code first.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.