我试图删除此div
代码的所有内容"广告":
<div id="ads">
<div id="ad_overlay" style="position: absolute; left: 20px; top: 22px; width: 944px; height: 786px;z-index:911;">
<iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://hdcast.org/ads/ad3.php" width="635" height="329" style="display: none !important;">
</iframe>
</div>
<div id="close" style="position:absolute;top:29px;left:190px;border:0;z-index:10000;" class="">
<a href="javascript:void(0)" onclick="removeOverlayHTML()">
<img src="http://www.hdcast.org/images/close_button.png" height="15" width="15">
</a>
</div>
</div>
&#13;
我通过这样做删除了ad_overlay
:
Form1.WebBrowser1.document.GetElementById("ad_overlay").OuterHtml = ""
但它对ad
无效。有什么想法吗?
答案 0 :(得分:0)
var ad = document.getElementById("ads");
function removeOverlayHTML() {
ad.remove();
}
&#13;
<div id="ads">
<div id="ad_overlay" style="position: absolute; left: 20px; top: 22px; width: 944px; height: 786px;z-index:911;"><iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://hdcast.org/ads/ad3.php" width="635" height="329" ></iframe></div>
<div id="close" style="position:absolute;top:29px;left:190px;border:0;z-index:10000;" class="">
<a href="javascript:void(0)" onclick="removeOverlayHTML()"><img src="http://www.hdcast.org/images/close_button.png" height="15" width="15"></a></div>
</div>
&#13;
此功能可让您删除包含其他两个<div>
的{{1}},其中包含简单的代码行<div>
和变量ad.remove();
到元素。