Lee W, MVP
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"?
How can I redirect to "_parent"?
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.a sp")
END IF
%>
Figure, as of now, every page uses an "include" file that says:
<%
IF SESSION("ACTIVE") <> "TRUE" THEN
RESPONSE.REDIRECT("login.a
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
<%
IF SESSION("ACTIVE") <> "TRUE" THEN
%>
<script language="JavaScript">
window.open "your_page.asp";
</script>
<%
END IF
%>
hongjun
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
ASKER
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...
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...
ASKER
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
%>
<%
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
hongjun
ASKER
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.
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.
This is the technique I use....
<%
if session("seclevel") < 2 then
session.abandon
response.write "<html><body onload='top.location='/'>< /body></ht ml>"
else
'happy auth'ed user stuffs
end if
%>
<%
if session("seclevel") < 2 then
session.abandon
response.write "<html><body onload='top.location='/'><
else
'happy auth'ed user stuffs
end if
%>
<script language="JavaScript">
window.open "your_page.asp";
</script>
hongjun