estrarre una variabile dal querystring


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.