asp中如何得到url地址

来源:百度知道 编辑:UC知道 时间:2024/05/28 09:41:48
<script src=xxx.asp></script>
把以上代码放在一个a.asp的页面里,
当打开页面http://localhost/abc/def/a.asp?id=5
请问在xxx.asp中能得到http://localhost/abc/def/a.asp?id=5这个url地址吗
不能用include,因为a.asp有可能是html静态页面,所以只能<script src=/xxx.asp></script>的方式调用.
更正一下:xxx.asp是在根目录下,而a.asp(或a.html)是在/abc/edf/目录下。两个文件非同一级目录。
所以不是简单的Request.ServerVariables("URL")就能得到,Request.ServerVariables("URL")只能得到“/xxx.asp”,而不是/abc/edf/a.asp
我想得到的是/abc/edf/a.asp这个页的路径,谢谢大家

HTTP=Request.ServerVariables("HTTP_REFERER")
这句话好像就可以了.

sURL=lcase(Request.ServerVariables("HTTP_HOST")) 这句是获取当前URL
squery=lcase(Request.ServerVariables("QUERY_STRING")) 这句是获取URL后面所带的所有参数

HTTP=squery+sURL 最后两个合并在一起就可以了

用include
<!--#include file="xxx.asp"-->

HTTP=Request.ServerVariables("HTTP_REFERER")
就可以了