Solved

Response.Redirect w/targets

Posted on 2002-05-11
10
1,580 Views
Last Modified: 2007-11-27
I have a web site that allows users to log in.  Every page accessed checks to ensure their session is still valid.  If it isn't it's supposed to redirect them back to the login page.  Problem is, the site starts out as a single page, then, upon login Redirects people to a frameset page.  So if any one of the frameset pages redirects the user, the login window would appear in the frameset.

How can I redirect to "_parent"?
0
Comment
Question by:Lee W, MVP
  • 5
  • 4
10 Comments
 
LVL 33

Expert Comment

by:hongjun
ID: 7004119
Redirect to _parent? This can be solved using JavaScript.

<script language="JavaScript">
    window.open "your_page.asp";
</script>

hongjun
0
 
LVL 95

Author Comment

by:Lee W, MVP
ID: 7004128
I don't know JavaScript much at all.  Please provide the code I would use.

Figure, as of now, every page uses an "include" file that says:

<%
IF SESSION("ACTIVE") <> "TRUE" THEN
   RESPONSE.REDIRECT("login.asp")
END IF
%>
0
 
LVL 33

Expert Comment

by:hongjun
ID: 7004133
Below example code will open login.asp with target="_parent".


<%
IF SESSION("ACTIVE") <> "TRUE" THEN
%>
<script language="JavaScript">
   window.open "your_page.asp";
</script>
<%
END IF
%>


hongjun
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 33

Accepted Solution

by:
hongjun earned 70 total points
ID: 7004136
Should be this

<%
IF SESSION("ACTIVE") <> "TRUE" THEN
%>
<script language="JavaScript">
  window.open "login.asp";
</script>
<%
END IF
%>


hongjun
0
 
LVL 95

Author Comment

by:Lee W, MVP
ID: 7004714
That opens a new window.  I don't want a new window, I want the PARENT of the frameset to be the window that gets the login window.  Basically, I want to cancel the frameset and go back to the login page.  
0
 
LVL 95

Author Comment

by:Lee W, MVP
ID: 7004729
The only reason I'm accepting this as an answer is because you said to use javascript.

The apparently correct way to do it is:

<%
IF SESSION("ACTIVE") <> "TRUE" THEN
%>
     if (document.images)
          location.replace("http://www.somesite.com/index.asp");
     else
          location.href = "index.asp";
     //--></SCRIPT>
<%
END IF
%>

I found the above sample on www.irt.org - They seem to have an extensive FAQ about javascript and other web related stuff...
0
 
LVL 95

Author Comment

by:Lee W, MVP
ID: 7004731
I missed a line - to clarify for anyone else who wants the answer:


<%
IF SESSION("ACTIVE") <> "TRUE" THEN
%>
<SCRIPT LANGUAGE="JavaScript">
    <!--
    if (document.images)
         location.replace("http://www.somesite.com/index.asp");
    else
         location.href = "index.asp";
    //-->
</SCRIPT>
<%
END IF
%>
0
 
LVL 33

Expert Comment

by:hongjun
ID: 7005640
Why a C grade here? You request for code to do target="_parent" and I gave you. Perhaps you should rephrase your question. This is misleading.

hongjun
0
 
LVL 95

Author Comment

by:Lee W, MVP
ID: 7006345
Because it didn't work... I tried your code and it opened a new window - an effective "target=_blank", it did not load the page in the _parent window.

I'll clarify. I have one browser window.   I open frame based web page.  20 minutes later, the session expires.  Currently, my code (which I realized doesn't work) redirects the current frame to the login page.  Essentially the same as the ASP code I first posted.  Your code opens a new browser window, leaving the old one there - NOT what I wanted.  I want to stay with the 1 browser window and basically load a non-frames page to tell the user to re-login.  If you can provide a better answer, I'll see if I can't get this answer grade changed.
0
 

Expert Comment

by:daveabad
ID: 7531555
This is the technique I use....

<%
if session("seclevel") < 2 then
  session.abandon
  response.write "<html><body onload='top.location='/'></body></html>"
else
  'happy auth'ed user stuffs
end if
%>

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

838 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question