父级的javascript重定向

Cir*_*gas 3 javascript redirect

可能重复:
使用JavaScript从iframe操作重定向父窗口

我有一个带有iframe的页面,在这个iframe的内容中,所有窗口都有重定向,我该怎么做?

尝试:

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

如果页面是在框架中打开还是向上打开,我可以得到?

 if(isiframe) window.top.location.href
Run Code Online (Sandbox Code Playgroud)

---解决方案---

if($("#cboxOverlay", top.document).length > 0)
  if($("#cboxOverlay", top.document).css("display") != 'none')
    window.top.location.href = '{{ path('portada') }}';
Run Code Online (Sandbox Code Playgroud)

fel*_*pes 5

如果它们位于您可能使用的同一域中

window.top.location.href = 'logged.html';
Run Code Online (Sandbox Code Playgroud)

否则stackoverflow中有很多类似的线程:

使用Javascript从Iframe进行跨域URL访问

使用JavaScript从iframe操作重定向父窗口