如题,求助各位达人,先谢了。
------解决方案--------------------
- HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <style type="text/css"> #pop{border:#000; background-color:#CCC; position:absolute; left:50px; top:50px;width:200px;height:500px; display:none} #btn{color:#f00} </style> <script type="text/javascript"> function $(id){return document.getElementById(id);} window.onload = function(){ document.onclick = function(e){ $("pop").style.display = "none"; } $("btn").onclick = function(e){ $("pop").style.display = "block"; e = e||event; stopFunc(e); } $("pop").onclick = function(e){ e = e||event; stopFunc(e); } } function stopFunc(e){ e.stopPropagation?e.stopPropagation():e.cancelBubble = true; } </script> </head> <body> <span id="btn">打开层</span> <div>aaaaaaaaaaaa</div> <div>aaaaaaaaaaaa</div> <div>aaaaaaaaaaaa</div> <div>aaaaaaaaaaaa</div> <div>aaaaaaaaaaaa</div> <div>aaaaaaaaaaaa</div> <div id="pop"> 浮层,点击这个浮层以外的区域,都可以隐藏这个浮层,怎么做啊,多谢了 <p><a href="http://www.baidu.com" target="_blank">最主要的是点这个div里面的链接,div照样不隐藏</a></p> </div> </body> </html>