均来自网上搜集: //方式一 if (self.frameElement && self.frameElement.tagName == "IFRAME") { alert('在iframe中'); } //方式二if (window.frames.length != parent.frames.length) { alert('在iframe中');}//方式三if (self != top) { alert('在iframe中');}以上有一种方法用任何一种都可以判断代码是否在iframe中.//-----------------------------------------------------------------------------如果没有被iframe引用的话,则location与top.location是一样的!if(top.location != location){ top.location.href= location.href; }
联系客服