Link to home
Start Free TrialLog in
Avatar of bagni99
bagni99

asked on

reload parent from iframe

Hi,
This is probably easy but I can't seem to find the perfect answer to this.

I have an iframe that defaults to a login page when the session times out.  What I want is the parent page to load the login page when the iframe session times out.

This is the iframe code that I need to change:

<%
If Not IsLoggedIn And Request.Cookies(ewProjectName)("autologin") = "autologin" And Request.Cookies(ewProjectName)("password") <> "" Then Response.Redirect "login.asp"
Call LoadUserLevel()
If IsLoggedIn Then
      ewCurSec = CurrentUserLevelPriv("occasion of service")
Else
      ewCurSec = GetAnonymousPriv("occasion of service")
End If
If (ewCurSec And ewAllowList) <> ewAllowList Then Response.Redirect "login.asp"
%>

Thanks very much
bagni99
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

I guess you want to change
Then Response.Redirect "login.asp"
to
Then Response.Write "<script>top.location.replace('login.asp')</script>"
Avatar of bagni99
bagni99

ASKER

Thanks mplungjan, but the login page still opens in the iframe....I can't work it out.....I replaced both Response.Redirects with your script....bugger...bugger...bugger....can I say bugger here?

I even tried replacing the word 'top' with the word 'parent'...that didn't work either.
Is the parent from a different domain than the iframe?

If so, try "<script>window.open('login.asp','_top')</script>"

I know it looks weird, but that will not get the "Access Denied" error I think you might be getting if the iframe is from a different server (even a different protocol or port will be a different domain)

Michel

Avatar of bagni99

ASKER

tried it.....no good....just can't bust out of the iframe.
  Maybe there's something else I'm missing....I have to run but will keep at it.
try

"<script>alert('Trying to bust'); window.open('login.asp','_top')</script>"
try:

<script language=javascript>parent.location.reload()</script>

from the iframe
ASKER CERTIFIED SOLUTION
Avatar of HugoHiasl
HugoHiasl

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
@Inviser: He wants to load the login page that normally would be in the iframe
@Hugo: it is only if the iframe code wants to load the loginpage, so what is less complicated about your code?
guess Hugo is almost there.

Then Response.Write "<script>top.location = 'login.asp'</script>"
Avatar of bagni99

ASKER

HugoHiasl's answer did it, thank god.  Thank you all!
Hmm, very strange

My
top.location.replace('login.asp')

and
Hugo's
top.location="/yourloginpage.html";

and
Thirds
top.location = 'login.asp'

all will load login in the parent

ONLY reason Hugo's solution would be any better is if the code is in the login page.
If the code in the iframe is different than the login page, then my code will not break the back button
Avatar of bagni99

ASKER

You got it....I put Hugos code in the actual login page.
Right, Not easy to guess