Home  >  Article  >  Web Front-end  >  如何修改iframe里面元素的css样式,不跨域_html/css_WEB-ITnose

如何修改iframe里面元素的css样式,不跨域_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-21 09:03:001692browse

请教一下,如何修改iframe里面元素的css样式,不跨域。
我现在iframe里面加载了一个html文件,html里面的内容无法修改,是其他程序生成的。
但是里面的图片无法显示,现在需要把iframe里面的html的所有图片全部隐藏起来,应该如何实现呢?方法能兼容IE所有浏览器。谢谢


回复讨论(解决方案)

http://bbs.csdn.net/topics/390080209

js控制。。。。

如何控制,能帮忙写一个实例好么。。

已解决,贴出解决方法

<script>    function hideImg(i) {        var imgs = i.contentWindow.document.getElementsByTagName('img');        for(var i=0;i<img s.length;i++)imgs[i].style.display='none'    }</script alt="如何修改iframe里面元素的css样式,不跨域_html/css_WEB-ITnose" ><iframe onload="hideImg(this)"

给iframe添加onload事件,然后遍历所有img隐藏起来,注意file浏览时不用用webkit核心浏览器,如chrome和360急速模式,无法互访

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn