您好,欢迎来到咤帕游戏。
搜索
您的当前位置:首页jquery操作iframe中的元素和js函数_html/css

jquery操作iframe中的元素和js函数_html/css

来源:咤帕游戏


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在同一个域名(因为不能跨域)

觉得不错,赞助我:

Copyright © 2019- zapatazone.com 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务