JavaScript获取url参数的值
2015-04-22来源:

JavaScript获取url参数的值

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技术专栏

推荐信息
Baidu
map