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");
精彩评论