jQuery操作iframe中js函數的方法小結

字號:


    本文實例講述了jQuery操作iframe中js函數的方法。分享給大家供大家參考,具體如下:
    1、jquery操作iframe中的元素(2種方式)
    var tha = $(window.frames["core_content"].document).find("#trewuuu").html();
    var thb = $("#core_content").contents().find("#trewuuu").html();
    2、操作父界面中的元素(header:為某個元素的id)
    $('#header', parent.document).text()
    3、js調用iframe中的js函數(2種)
    window.frames["core_content"].window.testIframe2("11");
    document.getElementById("core_content").contentWindow.testIframe2("11");
    4、jquery調用iframe的js函數(帶參數的會有返回值)
    $("#core_content")[0].contentWindow.testIframe2("11");
    注意事項:
    要和所包含的iframe在同一個域名(因為不能跨域)
    希望本文所述對大家jQuery程序設計有所幫助。