首页 > 其他 > 详细

常用common方法

时间:2019-06-05 19:29:01      阅读:93      评论:0      收藏:0      [点我收藏+]

1.根据url中携带的参数名获取参数值

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

用法:url :http://localhost:8003/htmls/xxxxxxxx.html?guid=b3905077-ac9a-b9ba-5ba0-8ad411fa7d69&iType=2

var iType = getUrlParam("iType");

console.log(iType )

常用common方法

原文:https://www.cnblogs.com/liangpi/p/10981125.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!