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.

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.