How do I change the target frame of a Response.Redirect?

With client-side code, such as top.<target>.location.href= ...
ASP is on the server and does not "see" frames.

Instead of response.redirect, use code like this:

<%
   url = "http://example.com/"
   response.write("<script>" & vbCrLf)
   response.write("targetframename.location.replace('" & url & "');" & vbCrLf)
   response.write("</script>")
%>
Or this:
<%
 url = "http://example.com/"
 response.write("<script>" & vbCrLf)
 response.write("targetframename.location.href='" & url & "';" & vbCrLf)
 response.write("</script>")
%>

Notes: The replace() function does not alter the history list. Using the following syntax causes problems on some browsers:

response.redirect("javascript:framename.location.href='wherever';")

Avoid using that one unless you're in a controlled environment or you've tested it across your target audience.

If it is a form you're submitting to, you can use the following:

<form method="post" action="page.asp" target="framename">


asp breakout of frames target frame on redirect


Back To Top
© 1998 - 2024 psacake.com
Version 7.21 | Advertise on this site