參考下面方法:
function getUrlParameter(sParam) { var sPageURL = window.location.search.substring(1), sURLVariables = sPageURL.split('&'), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split('='); if (sParameterName[0] === sParam) { return typeof sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]); } } return false; };
例:
xxxx.html?token=adfUWE34&acc=Hldo&email=ss@tt.com
獲取:
var token = getUrlParameter('token'); var acc = getUrlParameter('acc'); var email = getUrlParameter('email');