开发者

Javascript top.location.replace with and without parent iFrame

开发者 https://www.devze.com 2023-04-01 11:29 出处:网络
I am using a frames page, which contains the following Javascript line: top.contentsFrame.location.replace(\"/main.jsp\");

I am using a frames page, which contains the following Javascript line:

top.contentsFrame.location.replace("/main.jsp"); 

I want to run this page both inside an iFrame, as well as independenty开发者_JS百科. In an iFrame it doesn't work, because the top attribute now returns the iFrame. So it can't find "contentsFrame" anymore.

What would be the easiest way to fix this?

Cheers!


you should use

parent.top.location.replace("/main.jsp");
0

精彩评论

暂无评论...
验证码 换一张
取 消