开发者

Javascript top.location.replace with and without parent iFrame

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜