Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript redirect on parent [duplicate]

Possible Duplicate:
Redirect parent window from an iframe action using JavaScript

I have a page with an iframe and in content of this iframe have a redirection on all window, how can I make this?

Tried:

window.location.href = 'logged.html';

I can get if the page is opened in a frame or a up?

 if(isiframe) window.top.location.href

--- solution ---

if($("#cboxOverlay", top.document).length > 0)
  if($("#cboxOverlay", top.document).css("display") != 'none')
    window.top.location.href = '{{ path('portada') }}';
like image 922
Ciro Vargas Avatar asked Mar 06 '26 20:03

Ciro Vargas


2 Answers

If they are in the same domain you may use

window.top.location.href = 'logged.html';

Otherwise there are a lot of similar threads in stackoverflow:

Cross Domain URL Access from Iframe using Javascript

Redirect parent window from an iframe action using JavaScript

like image 58
felipeclopes Avatar answered Mar 08 '26 10:03

felipeclopes


window.top.location.href = "http://www.yourwebsite.com"; (but the IFrame and the top window must be on the same domain.

like image 40
Samson Avatar answered Mar 08 '26 10:03

Samson