随笔 - 106  文章 - 0 评论 - 6 阅读 - 18万
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

关键字: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.getElementByIdx_x_x("core_content").contentWindow.testIframe2("11"); 


4、jquery调用iframe的js函数(带参数的会有返回值) 
$("#core_content")[0].contentWindow.testIframe2("11"); 

5. 调用父页面js函数,直接用parent.myFunction();

注意事项: 

1、要和所包含的iframe在同一个域名(因为不能跨域)

版权声明:本文为博主原创文章,未经博主允许不得转载。

posted on   鸟叔手擒大数据  阅读(161)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示