讀取URL上的參數

用javascript來讀取目前網頁URL上的參數

 asp server side可以用request()函數來讀取網址上的參數,但client side的javascript要怎麼做到同樣的事情? Jordan在stackoverflow尚提供了這個solution:

function getURLParameter(name) {
  return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [null, ''])[1].replace(/\+/g, '%20')) || null;
}

Usage:

ID = getURLParameter('ID');