使用javascript onclick关闭div

时间:2017-03-25 12:32:47

标签: javascript html

我有这个代码显示iframe叠加我想要做的是关闭整个表单"关闭"和#34;跳过并访问网站"点击。



<div id="hstp_10516_interstitial" width="1060px" height="520px" style="background-color: rgb(0, 0, 0) !important; font-size: 10px !important; font-family: Arial, Helvetica, sans-serif !important; position: fixed !important; z-index: 2147483641 !important; border: 5px solid rgb(0, 0, 0) !important; left: 50% !important; top: 48% !important; width: 1060px !important; height: 520px !important; border-radius: 7px !important; box-shadow: rgba(50, 50, 50, 0.498039) 0px 0px 10px 0px !important;margin:-225px 0 0 -525px !important;">
<div id="hstp_10516_interstitial_pub" style="background-color: rgb(0, 0, 0) !important; color: rgb(255, 255, 255) !important; width: 140px !important; float: left !important; text-align: left !important; padding: 4px !important; cursor: pointer !important;font-family:Arial, Helvetica, sans-serif !important;">[Close]</div>
<div id="hstp_10516_interstitial_header" style="height: 15px !important; font-size: 10px !important; background-color: rgb(0, 0, 0) !important; padding: 4px !important; color: rgb(255, 255, 255) !important; float: right !important; width: 140px !important; text-align: right !important; cursor: pointer !important;font-family:Arial, Helvetica, sans-serif !important;">Skip and Visit Site »</div>
<div id="hstp_10516_interstitial_div" style="width: 1050px !important; height: 490px !important;overflow:hidden !important;">
<iframe id="hstp_10516_interstitial_iframe" src="http://example.com" frameborder="0" width="1060px" height="480px" style="width: 1050px !important; height: 480px !important; background-color: rgb(255, 255, 255) !important; position: absolute !important; z-index: 2147483642 !important; top: 30px !important; left: 0px !important; cursor: pointer !important; border: none !important; margin: 0px !important;border-radius:7px !important;"></iframe>
</div>
</div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

document.getElementById('CloseButton').click = function(){
    document.getElementById('hstp_10516_interstitial_iframe').style.display='none';

}

其中,CloseButton是您要单击以关闭框架的按钮的ID。