Click anywhere on the page to close the hidden layer of a new implementation method, there is a need for friends can refer to the comparison, you can expand the relevant functions on this basis. (You can also tie an order in the frames page to add a bit of your own.) )
<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><title>Click anywhere on the page to close the hidden layer</title><Scripttype= "Text/javascript">varDocument_click_hide_object=function(A, b) {vara=document.getElementById (a); varb=document.getElementById (b); //Show B When you click aA.addeventlistener ("Click",function() {B.style.left=A.offsetleft+ "px"; B.style.top=A.offsettop+A.clientheight+ "px"; B.style.display="Block"; B.setattribute ("Data-close","false"); Window.settimeout (function() {B.setattribute ("Data-close","true"); }, -); }); B.addeventlistener ("Click",function() {B.setattribute ("Data-close","false"); Window.settimeout (function() {B.setattribute ("Data-close","true"); }, -); }); Document.addeventlistener ("Click",function() {window.settimeout (function() { if(B.getattribute ("Data-close") == "true") {B.setattribute ("Data-close","false"); B.style.display="None"; } }, -); });} Window.onload=function() {Document_click_hide_object ("a","b");}</Script><styletype= "Text/css">#a{padding:3px 10px;Border:1px solid #CCC;position:Absolute;Top:50px; Left:100px;width:50px;text-align:Center;Height:30px;Line-height:30px;cursor:Pointer;}#b{padding:3px 10px;Border:1px solid #CCC;position:Absolute;padding:20px;Display:None;background:#FFF;}</style></Head><Body><DivID= "a">Show</Div><DivID= "B">I show you click on me after I am not automatically closed, click on the page anywhere will be closed oh, try it!</Div></Body></HTML>
Click anywhere on the page to close the hidden layer