好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

jquery操作iframe中的元素和js函数_html/css_WEB-ITnose

1、jquery操作iframe中的元素(2种方式)

var str = $(window.frames["iframe"].document).find("#ljiong").html(); var stk = $("#iframe").contents().find("#ljiong").html(); 

2、操作父界面中的元素(header:为某个元素的id)

$('#header', parent.document).text();window.parent.$("#header").text(); 

3、js调用iframe中的js函数(2种)

window.frames["ljiong"].window.testIframe2("ljiong"); document.getElementById("ljiong").contentWindow.testIframe2("ljiong"); 

4、jquery调用iframe的js函数(带参数的会有返回值)

$("#ljiong")[0].contentWindow.testIframe2("ljiong"); 

5. 调用父页面js函数,直接用:

parent.myFunction(); 

注意事项:

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

觉得不错,赞助我:

查看更多关于jquery操作iframe中的元素和js函数_html/css_WEB-ITnose的详细内容...

  阅读:36次