Link to home
Start Free TrialLog in
Avatar of Lee W, MVP
Lee W, MVPFlag for United States of America

asked on

Response.Redirect w/targets

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"?
Avatar of hongjun
hongjun
Flag of Singapore image

Redirect to _parent? This can be solved using JavaScript.

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

hongjun
Avatar of Lee W, MVP

ASKER

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
%>
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
ASKER CERTIFIED SOLUTION
Avatar of hongjun
hongjun
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.  
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...
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
%>
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
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.
Avatar of daveabad
daveabad

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