url常见操作

自动刷新当前的url

window.location.reload();

url跳转:

location.href=src+"?num="+data+"&device="+device1+"&situation="+situation1+"&checkSituation="+checkSituation1;//跳转到另一个页面,//可以传递其他参数到另一个页面

本窗口打开另一个页面

window.open(son_url,"_self");

 

获取url中的参数

console.log(window.location.search.substr(1));//获取url中?后的字符串

/*通过正则获取url中的参数*/

varname = function (name){

   var reg = new RegExp("(^|&)"+name +"=([^&]*)(&|$)");

   var r =window.location.search.substr(1).match(reg);

   if(r!=null)return decodeURI(r[2]); returnnull;

}

console.log(name("dwName"));


猜你喜欢

转载自blog.csdn.net/xiaoshenhuo/article/details/78017513