Posted By

BoNzO on 03/13/09


Tagged

url querystring variable


Versions (?)

estrarre una variabile dal querystring


 / Published in: JavaScript
 

  1. <script type="text/javascript"><![CDATA[
  2. function gup( name )
  3. {
  4. name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  5. var regexS = "[\\?&]"+name+"=([^&#]*)";
  6. var regex = new RegExp( regexS );
  7. var results = regex.exec( window.location.href );
  8. if( results == null )
  9. return "";
  10. else
  11. return results[1];
  12. } ]]>
  13. </script>
  14.  
  15.  
  16. <script type="text/javascript">
  17. var cat_corrente = gup("id");
  18. document.write(cat_corrente);
  19. </script>

Report this snippet  

You need to login to post a comment.