正文

asp获取当前完整路径(url)的函数代码(asp 获取td)这都可以

文章摘要

这篇文章展示了一个VBScript脚本 named GetUrl, 其作用是根据服务器变量动态构建URL。脚本首先根据HTTPS标记确定使用http或https协议,然后拼接服务器名、端口(非默认端口)、路径以及可能的查询参数。通过条件判断,脚本确保了在不同环境(如HTTPS启用或关闭、不同端口)下的正确 URL 构建。该脚本的目的是提高网站的兼容性和灵活性,适用于 web 开发中的动态 URL 生成场景。

 <% function GetUrl() on Error Resume Next Dim strTemp if LCase(request.ServerVariables(“HTTPS”))=”off” Then strTemp=”http://” Else strTemp=”https://” end if strTemp=strTemp & Request.ServerVariables(“SERVER_NAME”) if Request.ServerVariables(“SERVER_PORT”) <> 80 Then strTemp=strTemp & “:” & Request.ServerVariables(“SERVER_PORT”) strTemp=strTemp & Request.ServerVariables(“URL”) if trim(request.QueryString) <> “” Then strTemp=strTemp & “?” & Trim(Request.QueryString) GetUrl=strTemp End Function response.write GetUrl() %>