javascript html 静态页面传参数


复制代码 代码如下:

<script>
function getParam()
{
urlInfo=window.location.href; //获取当前页面的url
intLen=urlInfo.length; //获取url的长度
offset=urlInfo.indexOf("?"); //设置参数字符串开始的位置
strKeyValue=urlinfo.substr(offset,len); //取出参数字符串 这里会获得类似“id=1”这样的字符串
arrParam=strKeyValue.split("="); //对获得的参数字符串按照“=”进行分割
strParamValue=arrParam[1]; //得到参数值
alert("您要传递的参数值是"+strParamValue);
}
</script>


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3