JS解析URL网址参数
2018-8-23 乱云飞 评论(0) 浏览(949) 标签: JS代码 解析URL 解析网址参数
<script language="javascript"> www=location.search.substring(1,location.search.length); document.write("参数是:"+www+""); url = location.href; document.write("<br>本网页地址:"+url+""); protocol = location.protocol; document.write("<br>协议:"+protocol+""); host = location.host; document.write("<br>主机名和端口:"+host+""); port = location.port; document.write("<br>服务器端口是:"+port+""); path = location.pathname; document.write("<br>文件路径是:"+path+""); wenhao = location.search; document.write("<br>问号后面是:"+wenhao+""); maodian = location.hash.substring(1,location.hash.length); document.write("<br>锚点是:"+maodian+""); document.write("<hr color=red width=400 size=1 align=left>");//华丽的分割线 loc = wenhao.substring(wenhao.lastIndexOf('=')+1, wenhao.length); document.write("<br>等号后面是"+loc+""); xing = wenhao.substring(wenhao.lastIndexOf('*')+1, wenhao.length); document.write("<br>星号后面是"+xing+""); aite = wenhao.substring(wenhao.lastIndexOf('@')+1, wenhao.length); document.write("<br>@后面是"+aite+""); maohao = wenhao.substring(wenhao.lastIndexOf(':')+1, wenhao.length); document.write("<br>冒号后面是"+maohao+""); tanhao = wenhao.substring(wenhao.lastIndexOf('!')+1, wenhao.length); document.write("<br>叹号后面是"+tanhao+""); document.title = ("萤石云监控"+maodian+""); vid = wenhao.substring(wenhao.lastIndexOf('vid=')+3, wenhao.length); document.write("<br>vid是"+vid+""); uid = wenhao.substring(wenhao.lastIndexOf('uid=')+4, wenhao.length); document.write("<br>uid是"+uid+""); </script>