Jump to content

$_GET but with javascript from a hash url


shortysbest

Recommended Posts

If i have a url that looks like:

 

index.php?node=home#schedule&class=history

 

would there be a way for me to get only the part after the &.

 

for example in php i could use:

 

$_GET['class']

 

and that would be  "history"

 

I'm trying to do the same thing but in javascript with a hash.

 

 

I imagine you don't want the hash value to be "schedule&class=history" though..? If you want 'node' to equal "home#schedule" you'll need to encode the hash:

 

index.php?node=home%23schedule&class=history

 

Now you're able to return the query string as you expect it with window.location.search. This post contains an example of how you can return a specific parameter from that.

I imagine you don't want the hash value to be "schedule&class=history" though..? If you want 'node' to equal "home#schedule" you'll need to encode the hash:

 

index.php?node=home%23schedule&class=history

 

Now you're able to return the query string as you expect it with window.location.search. This post contains an example of how you can return a specific parameter from that.

 

 

Correct, I just want the value "history" such as if i could use php and use $_GET['class'] would return it.

 

I'm building a large website using hash url quite a bit to cut back on header requests as it will be used in every classroom 6 times a day in large schools for grading, attendance, etc.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.