1

js获取url参数的值

 2 years ago
source link: http://pein0119.github.io/2015/04/10/js%E8%8E%B7%E5%8F%96url%E5%8F%82%E6%95%B0%E7%9A%84%E5%80%BC/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

js获取url参数的值

2015-04-10 | 分类于js

一个小函数,用来获取当前url中的参数的值

function getUrlParam(param) {
var urlParam = window.location.search.substring(1).split('&')

var len = urlParam.length;
for (var i = 0; i < len; i++) {
if (param === urlParam[i].split('=')[0]) {
return urlParam[i].split('=')[1];
}
}

return null;
}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK