Response.redirect and specify target

Hello,

In Classic ASP, I have a redirect such as:

Response.Redirect LOGINPAGE & "?from=" &Server.URLEncode(strURL)

Our site has frames and the code as written will perform this redirect within the frame it's called, but I want it to redirect to the TOP target (the whole page).

Is this possible?
skbohlerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
Not from the server.  The server doesn't know that the page is embedded in a frame.  What you can do is modify  LOGINPAGE to send client-side code to detect if it is the top-most page loaded on the browser.  So, let's say that  LOGINPAGE="Login.asp", what you need to do in Login.asp is:
<!-- this is in Login.asp -->
<html>
<head>
<script>
// when Login.asp is embedded in a frame, "top.location" refers to the top-most containing window
if( top.location.href.indexOf("Login.asp") == -1 )
{
   top.location.href = "http://yoursite.com/Login.asp";
}
</script>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Paul MacDonaldDirector, Information SystemsCommented:
You can try 'target=_parent', which opens the page in the parent frame.
skbohlerAuthor Commented:
Could I use Javascript instead, like:

<script type="text/javascript">
          
    window.location='<%=LOGINPAGE & "?from=" &Server.URLEncode(strURL) %>'

           </script>
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

Big MontyWeb Ninja at largeCommented:
Could I use Javascript instead, like:

<script type="text/javascript">
           
    window.location='<%=LOGINPAGE & "?from=" &Server.URLEncode(strURL) %>'

           </script>

only if the page that's calling the script is the frame you want to go to login.asp. also keep in mind that you'll want to add some conditional if statement, otherwise it'll always go to login.asp in that current form
hieloCommented:
>> Could I use Javascript instead, like:
That's essentially what I suggested, but you need to use top.location so that the top-most window changes.  If you use window.location, you are just setting the frame's url.
skbohlerAuthor Commented:
Yes, it's in a conditional statement. Is there any problem with that Javascript syntax, other than missing top.location?
Big MontyWeb Ninja at largeCommented:
the syntax is correct, except for what you mentioned, yes
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.