Home

Tuesday, July 19, 2011

How to Get Parameters Values in HTML with Javascript

<a href="get.html?name=Dhirendra">Test</a>
<SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}
var frank_param = gup( 'name' );
//alert(frank_param);
document.write(frank_param);
</script>

1 comment:

  1. This is good code and successfully run ...
    thanks ds rathod.

    ReplyDelete

rathoddhirendra.blogspot.com-Google pagerank and Worth