请问如何获取url地址?

developerworks 2003-04-26 06:43:03
具体如下:
http://127.0.0.1/js/news.asp?id='1001'
在asp中或以利用request.servervariables("path_info")获取
http://127.0.0.1/js/news.asp
但是后面的id='1001'获取不到。
请问如下获取。谢谢。
...全文
53 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
developerworks 2003-05-04
  • 打赏
  • 举报
回复
谢谢大家!
zhangguagua 2003-04-26
  • 打赏
  • 举报
回复
用javascript得到楼主所说的后面的id='1001'
举个例子:
in 1.htm
<script>
function aa(){
location.href="2.htm?id=1001";}
</script>
<input type=button onclick="aa()">

in 2.htm
<script>
var s= location.search;
s= s.substring(1);
var s2 = s.split("=");
document.write(s2[0]+"="+s2[1]);
</script>
Estyle 2003-04-26
  • 打赏
  • 举报
回复
楼上方法是正统!
fason 2003-04-26
  • 打赏
  • 举报
回复
得到当前页面的地址
<%
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()
%>
Estyle 2003-04-26
  • 打赏
  • 举报
回复
直接用JS来写不行吗?
alert(window.location);
JS里面获取以后再想办法传给ASP.
iStringTheory 2003-04-26
  • 打赏
  • 举报
回复
需要自己写函数读取

给你一个思路:
1)找到“?”所在的位置
2)截取“?”之后的字符串
3)分析、提取各个参数

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧