สร้าง Function ต่อไปนี้...  function   GetUrlVars () {   
      var  vars = [], hash;   
       var  hashes = window.location.href.slice(window.location.href.indexOf( '?' ) + 1).split( '&' );   
  
       for  ( var  i = 0; i < hashes.length; i++) {   
           hash = hashes[i].split( '=' );   
           vars.push(hash[0]);   
           vars[hash[0]] = hash[1];   
      }   
  
       return  vars;   
 }   
  เวลาเรียกใช้ก็ส่ง Query String Name ที่อยากได้เข้าไป (ในที่นี้คือ "P")  GetUrlVars()[ "P" ]   
  การนำมาใช้งานจริงต้องมีการ validate นิดหน่อย..  if  ( GetUrlVar...
 
ความคิดเห็น
แสดงความคิดเห็น