This article describes the events and usages of JS when closing windows. Share to everyone for your reference, specific as follows:
/************ closes the window and submits the evaluation **************/window.onbeforeunload = function () {var pagewidth = Math.max (window.top.docume
Nt.body.scrollWidth, Window.top.document.documentElement.scrollWidth); var pageheight = Math.max (Window.top.document.body.scrollHeight, Window.top.document.documentElement.scrollHeight)
;
var cltheight = Math.max (Window.top.document.body.clientHeight, window.top.document.documentElement.clientHeight);
var width = 400;
var height = 200;
var layer = window.top.document.getElementById ("Zz_layer");
if (layer!= null) {layer.parentNode.removeChild (layer);
}//Mask layer var layer= window.top.document.createElement ("div");
Layer.id = "Zz_layer";
Layer.style.filter = "Alpha (opacity=38)";//ie layer.style.opacity = "0.38";//ff layer.style.width = PageWidth + "px";
Layer.style.height = pageheight + "px";
layer.style.position= "Absolute";
layer.style.top = 0;
Layer.style.left = 0;
Layer.style.backgroundColor = "#000"; Layer.style.zIndex = "9998 ";
Window.top.document.body.appendChild (layer);
Evaluation window var newbox = document.getElementById ("Kf_pj_div");
Newbox.style.zIndex = "9999";
Newbox.style.display = "block";
Newbox.style.width = width + "px";
Newbox.style.height = height + "px";
Newbox.style.border = "#565656 4px solid";
Newbox.style.background = "#FFFFFF";
Newbox.style.position = "absolute";
Newbox.style.left = pagewidth/2 + "px";
Newbox.style.top = (CLTHEIGHT/2) + "px";
if (Height/2 > (CLTHEIGHT/2)) {Newbox.style.marginTop = (-(CLTHEIGHT/2)) + "px";
}else{Newbox.style.marginTop = (-HEIGHT/2) + "px";
} if (Width/2 > (PAGEWIDTH/2)) {Newbox.style.marginLeft = (-(PAGEWIDTH/2)) + "px";
}else{Newbox.style.marginLeft = (-WIDTH/2) + "px"; Return "You have not yet evaluated customer service services, please click ' Cancel ' rating!"
";
}; function Mydiv_resize () {var pagewidth = Math.max (Window.top.document.body.scrollWidth,
Window.top.document.documentElement.scrollWidth); var pageheight = Math.max (Window.top.document.body.scrollHeight, WIndow.top.document.documentElement.scrollHeight);
var cltheight = Math.max (Window.top.document.body.clientHeight, window.top.document.documentElement.clientHeight);
var cltwidth = Math.max (Window.top.document.body.clientWidth, window.top.document.documentElement.clientWidth);
var width = 400;
var height = 200;
var layer = window.top.document.getElementById ("Zz_layer");
if (layer!= null) {//Matte layer Layer.style.width = pagewidth + "px";
Layer.style.height = pageheight + "px";
}//Evaluation window var newbox = document.getElementById ("Kf_pj_div");
Newbox.style.left = cltwidth/2 + "px";
Newbox.style.top = (CLTHEIGHT/2) + "px";
if (Height/2 > (CLTHEIGHT/2)) {Newbox.style.marginTop = (-(CLTHEIGHT/2)) + "px";
}else{Newbox.style.marginTop = (-HEIGHT/2) + "px";
} if (Width/2 > (PAGEWIDTH/2)) {Newbox.style.marginLeft = (-(PAGEWIDTH/2)) + "px";
}else{Newbox.style.marginLeft = (-WIDTH/2) + "px";
} window.onresize = Mydiv_resize;
More readers interested in JavaScript-related content can view the site topics: "JavaScript window operations and tips summary", "javascript json operation tips Summary", "JavaScript switching effects and techniques summary", " JavaScript Search Algorithm Skills Summary, "JavaScript animation effects and techniques Summary", "JavaScript Error and debugging skills Summary", "JavaScript data structure and algorithm skills summary", "JavaScript traversal algorithm and skills summary" and The summary of JavaScript mathematical operational usage
I hope this article will help you with JavaScript programming.