用法 var id = getParam("id");
function getParam(strKey) { var url=document.URL; //var url="file://wqasdasd/www/1.html?id=2&index=5"; var para=""; if(url.lastIndexOf(strKey)<0) { } else { if(url.lastIndexOf("?")>0) { url = url.substring(url.lastIndexOf("?")+1,url.length); var arr=url.split("&"); for(var i=0;i<arr.length;i++) { if(arr[i].split("=")[0] == strKey ) { return arr[i].split("=")[1]; } } } } return para; }
原文地址:https://www.cnblogs.com/youmingkuang/p/10504988.html
时间: 2024-10-10 06:38:29