萬盛學電腦網

 萬盛學電腦網 >> 腳本專題 >> javascript >> JS獲得URL超鏈接的參數值

JS獲得URL超鏈接的參數值

   var url = location.href;

  //獲取keyword的參數值

  var es=/keyword=/;

  es.exec(url);

  var result=RegExp.rightContext;

  例如:

  var url = location.href;

  //獲取pid的參數值

  var es=/pid=/;

  es.exec(url);

  var pid=RegExp.rightContext;

  var aurl = "&pid="+pid;

  alert(pid);//結果:&pid=37

copyright © 萬盛學電腦網 all rights reserved