我有这段代码,我想<div>
通过单击它外部来关闭此弹出窗口,而不仅仅是单击关闭按钮。
我怎样才能做到这一点?
<script language="JavaScript">
<!--
function displayPopup(alert_MSG) {
var theDetail = document.getElementById(alert_MSG);
theDetail.style.display="block";
}
function closePopup(alert_MSG) {
var theDetail = document.getElementById(alert_MSG);
if (theDetail.style.display=="block") {
theDetail.style.display="none";
}
}
-->
</script>
这是HTML链接:
<a href="javascript:displayPopup(<?=$id_pic?>)">open div here</a>
这是我的弹出窗口:
<div id="<?=$id_pic?>" class="myPopup" style="display:none;">
<div class="closeButton">
<a href="javascript:closePopup(<?=$id_pic?>)">Close</a>
</div>
Popup content here
</div>