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?
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

0

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.
0
skbohlerAuthor Commented:
Could I use Javascript instead, like:

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

           </script>
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
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
0
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.
0
skbohlerAuthor Commented:
Yes, it's in a conditional statement. Is there any problem with that Javascript syntax, other than missing top.location?
0
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
the syntax is correct, except for what you mentioned, yes
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.