//方式一 if (self.frameElement && self.frameElement.tagName == "IFRAME") { alert('在iframe中'); }
//方式二 if (window.frames.length != parent.frames.length) { alert('在iframe中'); }
//方式三 if (self != top) { alert('在iframe中'); }
第一、在iframe中查找父頁面元素的方法: $('#id', window.parent.document)
第二、在父頁面中獲取iframe中的元素方法: $(this).contents().find("#suggestBox")
第三、在iframe中調用父頁面中定義的方法和變量: parent.method parent.value
第四、父頁面調用iframe內的JS的方法,無須給iframe加id,只需用Jq選中iframe就行了 $("#id").find("iframe")[0].contentWindow.func()
