
通过js可以获取
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&])(&|$)", "i");
var r = windowlocationsearchsubstr(1)match(reg);
if (r != null) return unescape(r[2]); return null;
}
//这样调用:
alert(GetQueryString("参数名1"));
alert(GetQueryString("参数名2"));
alert(GetQueryString("参数名3"));
1、windowlocationhref(设置或获取整个 URL 为字符串)
var test = windowlocationhref;
alert(test);
返回:>
设置或获取对象指定的文件名或路径。
<script>
alert(windowlocationpathname)
</script>
设置或获取整个 URL 为字符串。
<script>
alert(windowlocationhref);
</script>
设置或获取与 URL 关联的端口号码。
<script>
alert(windowlocationport)
</script>
设置或获取 URL 的协议部分。
<script>
alert(windowlocationprotocol)
</script>
<script>
alert(windowlocationhash)
</script>
设置或获取 location 或 URL 的 hostname 和 port 号码。
<script>
alert(windowlocationhost)
</script>
设置或获取 href 属性中跟在问号后面的部分。
<script>
alert(windowlocationsearch)
</script>
windowlocation
属性 描述
hash 设置或获取 href 属性中在井号“#”后面的分段。
host 设置或获取 location 或 URL 的 hostname 和 port 号码。
hostname 设置或获取 location 或 URL 的主机名称部分。
href 设置或获取整个 URL 为字符串。
pathname 设置或获取对象指定的文件名或路径。
port 设置或获取与 URL 关联的端口号码。
protocol 设置或获取 URL 的协议部分。
search 设置或获取 href 属性中跟在问号后面的部分。
如windowlocationhref 设置或获取整个 URL 为字符串。
RequestServerVariables("SERVER_NAME") 获取主机名RequestQueryString 获取url问号后面的所有参数名这样就可以写一个函数,来取得本页的完整的URLPrivate Function GetUrl()Dim ScriptAddress, M_ItemUrl, M_itemScriptAddress = CStr(RequestServerVariables("SCRIPT_NAME"))M_ItemUrl = ""If (RequestQueryString <> "") ThenScriptAddress = ScriptAddress & ""M_ItemUrl = M_ItemUrl & M_Item &"="& ServerURLEncode(RequestQueryString(""&M_Item&"")) & "&"Nextif right(M_ItemUrl,1)="&" then M_ItemUrl=left(M_ItemUrl,len(M_ItemUrl)-1)end ifGetUrl=RequestServerVariables("SERVER_NAME")&ScriptAddress & M_ItemUrl
#模拟测试网址: >
以上就是关于html页面的url怎样被获取全部的内容,包括:html页面的url怎样被获取、如何用js得到当前页面的url信息方法、如何用JS得到当前页面的URL信息等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)