jquery操作Iframe

2017-08-08  本文已影响0人  前端大鹏

父页面操作子页面


$("#iframe").load(function(){

var iframH = $(this).contents().find("html").outerHeight(true);

$(this).css("height", iframH+"px");

console.log(iframH);

});

子页面操作父页面


获取的简易写法

$("子集", "父级");

iframe里面内容操作父级

$(".header_title", window.parent.document).text();

等价于

$(window.parent.document).find(".header_title").text();

动态刷新Iframe


原生js写法:

document.getElementById('FrameID').contentWindow.location.reload(true);

jquery写法:

$('#iframe').attr('src',$('#iframe').attr('src'));

上一篇 下一篇

猜你喜欢

热点阅读