Posted By

vaibhav011286 on 10/04/11


Tagged


Versions (?)

$_GET() function to get any url parameter in javascript


 / Published in: JavaScript
 

  1. function $_GET(a) {
  2. return (a = location.search.match(RegExp("[?&]" + a + "=([^&]*)(&?)", "i"))) ? a[1] : a
  3. }
  4.  
  5. // example, if browser's url was like:
  6. // http://www.google.co.in/search?q=web&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
  7. // then you can get the value of any parameter like: alert($_GET('rls'));
  8. // returns org.mozilla:en-US:official as an alert

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: qoli on October 4, 2011

nice job.

You need to login to post a comment.