jQuery - change url ?param
- Started
- Last post
- 16 Responses
- dbloc
looking for a way to change the url param of ?plan=1a to ?plane=1b without refreshing the page.
anyone?
- dbloc0
found this...not sure I understand it.
http://www.samaxes.com/2011/09/c…
- monNom0
can you use location.hash?
location.hash='plan1b';
so url#plan1a becomes url#plan1b
make sure your anchors id's are not named the same and it should just fail.
- dbloc0
already set up with question marks...
using this to get it
if (isset($_GET["plan"])) {
$urlPlan = $_GET["plan"];
} else {
$urlPlan = '1a';
}
- monNom0
^that's not going to work unless you send it to the server.
- monNom0
in which case you can use ajax to pass the hash value to the server as the 'plan' variable, then handle the server response. No reload, bookmarkable, and should be okay with the back-button
- dbloc0
That GET is really only needed when the initially come to the page. I just wanted the user to be able to copy the url of the plan they are looking at with it switching the url.
I am switching everything out on the page with a funtion right now..I just need something to add to the funtion that switches out the url
- 3030
In other words - do you want to see the change of url in browser address bar?
- 3030
location.search - displays entire query string, but manipulation causes page refresh;
location.hash - doesn't refresh the page.
- dbloc0
oh ok...so there's no way to change it with refreshing the page unless it's a hash?
- monNom0
there's HTML5 history... but IDK about search strings (ie ?foo=bar)
- BabySnakes0
would need to use html pushState() and or replaceState().
But only HTML5.
https://developer.mozilla.org/en…
- dbloc0
don't really need the back button to work. I just want it to change the url in case someone copies the url and wants to come back to that particular page.
I already have it set to where if someone enters ?plan=1A it goes to plan 1A
- changing the url without changing the page content is useless! you need client side persistence, http://www.asual.com…********
- http://www.asual.com…********
- the content does change.dbloc
- changing the url without changing the page content is useless! you need client side persistence, http://www.asual.com…
- mikotondria30
Just put a [link to this page], and generate the url to copy under the link...
- yes just make it server side********
- oh well he said "without refreshing the page" so check my post it up here********
- yes just make it server side
- dbloc0
Thanks Snakes...I found this..
http://veerasundaravel.wordpress…