Breaking News

Editors Picks

Monday, January 9, 2012

How to access Query string in javascript?


<script type="text/javascript">
    function getParameterByName()
    {
      var name="QueryStringVariableName";
      var value='';
      name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
      var regexS = "[\\?&]" + name + "=([^&#]*)";
      var regex = new RegExp(regexS);
      var results = regex.exec(window.location.href);
      if(results == null)
        value= "";
      else
        value= decodeURIComponent(results[1].replace(/\+/g, " "));
    }

    script>

No comments :

Post a Comment

Contact Us

Name

Email *

Message *