Search code examples
javascriptphpvariablesget

Get GET variables from url using JavaScript jQuery


I want to read out a GET variable from an url using jquery

The domain is displayed like this

http://example.com/p/kT2Rnu35

And the original is :

http://example.com/php/page.php?id=kT2Rnu35

I want to get that id using jQuery from the page with the domain http://example.com/p/kT2Rnu35

I've tried window.location and other functions i found on stack overflow but nothing worked. Is it because i'm changing the url using htaccess ?


Solution

  • window.location.href will give you the url with parameters

    From there just use .split to break it apart