一、从浏览器url中获取到所需参数及信息;
function getQueryString(name) {
var that = this;
if(isNULL(name)){return null} //调用isnull
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
var param;
try{
param = decodeURI(r[2]);
}catch(e){
return null;
}
if (isNULL(r) == false) {
return param;
}
return null;
}getQueryString("name");调用函数输入入参即可获取url中的name值;
二、判断为空
function isNULL(exp){
return !!(exp == null || typeof exp == "undefined" || exp == 0 || exp == "null" || exp == [] || exp == '{}' || exp == '' || exp == {});},
三、判断空对象
function isEmptyObject( obj ) {
var name;
for ( name in obj ) {
return false;
}
return true;
}