Advertisement
Guest User

Untitled

a guest
Jul 29th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. /**
  2. * 解析URL 查询字符串中的特定参数
  3. * @param key 想要获取的参数名称, 字符串
  4. * @param url 被解析的url字符串, 或者纯参数(?后面的部分)也可以.
  5. * @returns {undefined} 返回参数值, 如果url中没有这个key, 返回 undefined
  6. */
  7. var getParaByKey = function(key, url) {
  8. var reg = new RegExp("(\\?|\&)" + key + "=" + "(.*?)(\$|\&|\#)");
  9. return reg.exec(url) ? reg.exec(url)[2] : undefined;
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement