asp中使用js的变量

来源:百度知道 编辑:UC知道 时间:2024/06/07 09:28:21
代码如下,请问一下如何修改,这是在frame中的文件
<%
dim GetUrl
%>
<script language="javascript" type="text/javascript">
GetUrl1=window.parent.location.href; //这个就是父窗口URL
<%=GetUrl%>=document.write(GetUrl1);
</script>
<%
Response.Write "网址的内容:"&GetUrl&""
%>
因为这个代码是在frame中,所以要取得当前网址需要用到js,js的值没法传递到asp中...

你想修改什么?

这段代码就是把弹出当前网页的网址显示在当前网页中.

<%
dim GetUrl
GetUrl = "<script>var GetUrl = window.parent.location.href;document.write(GetUrl);</script>"
Response.Write "网址的内容:"&GetUrl&""
%>

asp取当前url
<%
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")
end if
strTemp = strTemp & Request.ServerVariables("URL")
If Trim(Request.QueryString) <> "" Then
strTemp = strTemp & "?" & Trim(Request.QueryString)
end if
GetUrl