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");

注意事項:
1、要和所包含的iframe在同一個域名(因爲不能跨域)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章