<script type="text/javascript">
function openPOP(e) {
document.getElementById("pop").style.display = "block";
e = e || window.event;
stopEvent(e);
}
document.onclick = function() {
document.getElementById("pop").style.display = "none";
}
window.onload = function() {
document.getElementById("pop").onclick = function(e) {
e = e || window.event; stopEvent(e); } } //阻止事件冒泡
var stopEvent = function(e) {
if (e.stopPropagation) { e.stopPropagation(); } else { e.cancelBubble = true; }
}
</script>
<style type="text/css">
#pop
{
border: 1px solid black;
width: 100px;
height: 100px;
display: none;
position: absolute;
left: 200px;
background-color: #eee;
}
</style>
<div id="pop">
I'm POP
</div>
<input type="button" value="pop" οnclick="openPOP(event);" />
关闭/隐藏div
最新推荐文章于 2021-06-26 04:59:03 发布