沒找到很好的方法
只好用DOM方法與jquery方法結合的方式實現了
1.在父窗口中操作 選中IFRAME中的所有單選鈕
$(window.frames["iframe1"].document).find("input[@type='radio']").attr("checked","true");
2.在IFRAME中操作 選中父窗口中的所有單選鈕
$(window.parent.document).find("input[@type='radio']").attr("checked","true");
iframe框架的:<iframe src="test.html" id="iframe1" width="700" height="300" frameborder="0" scrolling="auto"></iframe>
IE7中測試通過 回去你自己試試吧
剛才google到的,補充一下
I beat my head against this wall for quite some time.
Try this:
$("#myid", top.document);
the top.document tells the selector to target the myid element which
exists in the topmost document (your parent page). In order for this
to work, jquery must be loaded in the file which is viewed through the
iframe.
我的代碼
$('#parentElem', top.document).append('<div class="imgbox" id="imgbox"><img class="img" src="pp.png" id="img"></div>');
upc不是說了么
1.在父窗口中操作 選中IFRAME中的所有單選鈕
$(window.frames["iframe1"].document).find("input[@type='radio']").attr("checked","true");
那選擇id自然就是依然使用find方法
$(window.frames["iframe1"].document).find("#id")
實際樓上上的方法本質上在Jq內部也是調用了find方法
父窗體調用IFrame中的方法(right)為ifram的id
document.frames["right"].expand();
父窗體:parent;
子窗體:opener;(window.opener.reload();)
上面的都是網上摘的,下面補充很重要的一點:
你可能已經注意到了,上面提及的都是自上而下的selector方法,也就是從上級window查找下級window(包括iframe創建的window),如果我們希望從下級window,比如希望通過iframe中的window找到iframe的parentNode,可以這樣:
var parentFrame=null;
if(window!=window.top){parentFrame=window.frameElement.name};
往下就可以直接$(.....
當然,一個topwindow中僅僅包含一個iframe時我們沒有必要這樣,但當若干iframe存在時,這個方法還是很有用的。
轉載自:http://hi.baidu.com/51plan/blog/item/381ee57e4c328e3f0cd7daac.html