您的位置:首页 > Web前端 > JQuery

jquery操作iframe中的js

2014-03-04 16:53 246 查看
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在同一个域名(因为不能跨域)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: