我有一个表单发布到iFrame
进行处理。然后,iFrame会在父窗口中向前发送一个表单以进行确认。iFrame重定向到错误页面
我在确认中添加了一个会话变量,表示该过程已完成。
如果用户单击后退按钮,iFrame中的表单会重定向到错误页面,但显然会显示在iFrame中。
我该如何在父级中创建错误页面触发器?
If Session("Complete") = 1 Then
Response.Redirect("default.asp?Re-Entry")
End If
我有一个表单发布到iFrame
进行处理。然后,iFrame会在父窗口中向前发送一个表单以进行确认。iFrame重定向到错误页面
我在确认中添加了一个会话变量,表示该过程已完成。
如果用户单击后退按钮,iFrame中的表单会重定向到错误页面,但显然会显示在iFrame中。
我该如何在父级中创建错误页面触发器?
If Session("Complete") = 1 Then
Response.Redirect("default.asp?Re-Entry")
End If
取而代之的是Response.Redirect的,你应该使用以下命令:
Response.Write("<script language='Javascript'>" + _
"window.parent.document.location.href = " + _
"'default.asp?Re-Entry';" + _
"</script>")
它会发送回的iFrame的JavaScript的一部分,将指示它的父(主页)导航到错误页面。
这里是我的测试的完整代码:
<%@ Language="VBScript" %>
<%
If Request("op") = "process" Then
If Session("Processed") = 1 Then
Response.Write("<script>" + _
"window.parent.document.location.href = " + _
"'error.asp?msg=AlreadyProcessed';" + _
"</script>")
Else
Session("Processed") = 1
Response.Write("<script>" +
"alert('Hello, " + Request("name") + "!');" + _
"</script>")
End If
Response.End
End If
%>
<html>
<body>
<iframe name="parallel" id="parallel" width="100%" height="50" />
<form method="POST" target="parallel" action="iFrame.asp">
<input type="hidden" name="op" value="process" />
<b>Your Name</b><br/>
<input type="text" name="name" width="250" /><br/>
<button type="submit">Submit!</button>
</form>
</body>
</html>
我希望它能帮助。
我认为ü[R使用的代码,根据我,如果u使用下面的代码,可以帮助ü
Response.Write("<scr" + "ipt language='Javascript'>" + _
"document.parent.navigate('default.asp?Re-Entry');" + _
"</scr" + "ipt>")
我试过的代码,但它没有工作是错误的?任何想法为什么? – 2011-02-13 14:05:14
页面出现任何JS错误,或者它什么也没做?你正在使用哪种浏览器? – 2011-02-13 14:23:26