9月27

Get the current page URL

| |
00:58编程杂谈  From: 本站原创
       There are times in your scripts when you are going to  want to get the current page URL that is shown the browser URL  window. For example maybe a page URL has  Querystring info appended to it and you need to send an email off to someone  with that same exact URL and Querystring information. There are plenty of other  reasons as well.

Here is some code to do it.

Lets say the  current page is simply "http://www.hecks.tk/showidc.asp"

This is all you  need to get you the current page URL
<%
Thispage ="http://"  & Request.ServerVariables("SERVER_NAME") &  Request.ServerVariables("URL")
%>


Now, if your page has  Querystring info and variables you want as well.
Like so "http://www.mysite,com/showidc.asp?ID=109"

you  would use code like this.

<%
Thispage ="http://"  & Request.ServerVariables("SERVER_NAME") &  Request.ServerVariables("URL") & "?" &  Request.Querystring
%>


If your page had Form info that might have been posted to it  you would use code like this.

<%
Thispage = "http://" &  Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL")  & "?" & Request.Form
%>


If your page had both  Querystring and Form info you could try code like  this.

<%
Thispage = "http://" &  Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL")  & "?" & Request.Querystring & Request.Form
%>


来源:Heck's Blog
地址:https://www.heckjj.com/post/228/
转载时须以链接形式注明作者和原始出处及本声明,否则将追究法律责任,谢谢配合!
阅读(1438) | 评论(0) | 引用(0)