页面调用Iframe中数据

<iframe src="html的路径(至于MVC中cshtml直接路径好像是不行的,得使用action进行请求出来的路径)" id="iframechild" style="position: absolute; left: 0px; top: 0px; width: 100%; height: 100%;"></iframe> 

$("#iframechild").contents().find("#store_image").attr("src", $("#show_image_1").attr("src"));

$("#iframe名称").contents()即为iframe的对象

js的写法:

 var _iframe = document.getElementById('iframeId').contentWindow;
        var _div =_iframe.document.getElementById('objId');

至于在iframe中获取父级页面的数据,则是直接使用parent,这个值就是父级窗口对象了

$(parent)即成为jquery对象

js的写法:

var _iframe = window.parent;
        var _div =_iframe.document.getElementById('parDiv');

 

posted @ 2017-09-21 14:45  Danlis  阅读(421)  评论(0编辑  收藏  举报