浏览器或web view向html页面传值

function getUrlParam(name) {  
   var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象  
   var r = window.location.search.substr(1).match(reg);  //匹配目标参数  
   if (r != null) {
       return unescape(r[2]);  //返回参数值 
   } else {
       return null; 
   }
}
var id = getUrlParam('id');
$(function(){
	$("#test").text(id);
});

猜你喜欢

转载自blog.csdn.net/m0_37456764/article/details/86665167