我有一个表单发布到iFrame
进行处理。然后,iFrame会在父窗口中将表单转发到确认页。
我在确认中添加了一个会话变量,表示该过程已完成。
如果用户点击后退按钮,iFrame中的表单会重定向到错误页面,但显然会显示在iFrame中。
如何在父级中触发错误页面?
If Session("Complete") = 1 Then
Response.Redirect("default.asp?Re-Entry")
End If
答案 0 :(得分:0)
您应该使用以下内容代替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>
我希望它有所帮助。
答案 1 :(得分:-1)
如果您使用以下可能对您有帮助的代码,我认为您使用的代码是错误的
Response.Write("<scr" + "ipt language='Javascript'>" + _
"document.parent.navigate('default.asp?Re-Entry');" + _
"</scr" + "ipt>")