JavaScript獲取url參數(shù)的值
ORYX.Utils = {
/**
* General helper method for parsing a param out of current location url
* @example
* // Current url in Browser => ""
* ORYX.Utils.getParamFromUrl("param") // => "value"
* @param {Object} name
*/
getParamFromUrl: function(name){
name = name.replace(/[\[]/, ", "]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
if (results == null) {
return null;
}
else {
return results[1];
}
}
}
更多信息請查看IT技術專欄