最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp 如何获取当前页面的网址
时间:2022-07-02 23:05:11 编辑:袖梨 来源:一聚教程网
有时,您可能希望获得当前页面的网址是在浏览器窗口中显示网址。例如,如果您想让您的访客提交博客张贴到Digg您需要得到同样的确切网址。有很多其他原因也很多。这里就是你如何能够做到这一点。
下面的代码添加到页面:
function curPageURL()
dim s, protocol, port
if Request.ServerVariables("HTTPS") = "on" then
s = "s"
else
s = ""
end if
protocol = strleft(LCase(Request.ServerVariables("SERVER_PROTOCOL")), "/") & s
if Request.ServerVariables("SERVER_PORT") = "80" then
port = ""
else
port = ":" & Request.ServerVariables("SERVER_PORT")
end if
curPageURL = protocol & "://" & Request.ServerVariables("SERVER_NAME") &_
port & Request.ServerVariables("SCRIPT_NAME")
end function
function strLeft(str1,str2)
strLeft = Left(str1,InStr(str1,str2)-1)
end function
%>
现在,您可以得到当前页面的URL使用行
response.write(curPageURL())
%>
如果您的网页有你想要查询字符串信息以及您可以尝试这样的代码:
response.write(curPageURL() & "?" & Request.ServerVariables("QUERY_STRING"))
%>
下面的示例演示如何做到这一点:
function curPageName()
dim pagename
pagename = Request.ServerVariables("SCRIPT_NAME")
if inStr(pagename, "/") > 0 then
pagename = Right(pagename, Len(pagename) - instrRev(pagename, "/"))
end if
curPageName = pagename
end function
response.write("The current page name is " & curPageName())
%>
相关文章
- 抖音短视频网页版:官方入口一键直达 12-19
- 漫画岛入口在哪 最新漫画岛入口一览 12-19
- 女神漫画独家入口-女神漫画韩漫全集在线免费畅读入口 12-19
- 哔哩哔哩国产大片视频入口在哪-最新哔哩哔哩国产大片视频地址链接分享 12-19
- 抖音电脑版网页版入口-抖音官网PC端在线观看 12-19
- 126邮箱登录官网极速稳定-免费秒开收件箱畅快收发 12-19