我想删除所有要在HTML文件中显示的图片,其中包含刷新的iframe。
是否有可能使用CSS或JavaScript的方法呢?
加载iframe的页面使用以下代码。
function reloadIFrame() {
console.log('reloading..');
document.getElementById('iframe').contentWindow.location.reload();
}
window.setInterval(reloadIFrame, 3000);

body {
margin: 0px;
}
h1 {
font-family: arial;
font-size: 50%;
}
iframe {
width: 100%;
height: 800px;
}
div.top {
background-color: rgba(2, 109, 8, 0.83);
height: 1%;
width: 100%;
}

<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" href="news.png" type="image/x-icon" />
<title>Chat</title>
</head>
<body>
<div class="top">
<img src="news.png" alt="newsicons" height="31" width="31">
<h1>News</h1>
</div>
<iframe id="iframe" src="http://www.bbc.com/news/world"></iframe>
</body>
</html>
&#13;
答案 0 :(得分:0)
您可以使用javascript执行此操作。查看下面的更新代码段。
if(document.getElementById('iframe')) {
var images = document.getElementsByTagName('img');
for (i = 0; i < images.length;i++ ) {
images[i].style.display = "none";
}
}
&#13;
<div class="top">
<img src="news.png" alt="newsicons" height="31" width="31">
<h1>News</h1>
</div>
<iframe id="iframe" src="http://www.bbc.com/news/world"></iframe>
&#13;