jQuery在iframe里取得父窗口的某個元素的值


提供一款jQuery在iframe里取得父窗口的某個元素的值實現,這個iframe用js也差不多,有需要的朋友可以參考一下。

1.在父窗口中獲取指定iframe(testiframe) id 為 testid 的class

$(window.frames["testiframe"].document).find("#testid").attr('class');

2.在IFRAME中獲取父窗口中id為testid的class

$(window.parent.document).find("#testid").attr('class');

iframe框架的:

<iframe src="test.html" id="testiframe" width="700" height="300" frameborder="0" scrolling="auto"></iframe>

 

釋放某個Iframe的寫法:

wrapper.iframeRemove = function () {
    var frame = $(frames["showIFrame"])[0];//showIFrame 指iframe的Id
    //$("iframe", topHelper.comWin).attr("src", "about:blank");
    frame.contentWindow.document.write('');//清空iframe的內容
    frame.contentWindow.close();//避免iframe內存泄漏
    frame.remove();//刪除iframe
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM