Yesterday the company's website needs to pop the window to prompt some information, I want to put the window of the JS code and pop-up windows HTML write together where need to call
Do not say so much, directly on the code, feel sure there will be compatibility problems, see must point out AH
<style> #H-dialog{display:none;position:absolute;z-index:9999999;width:400px;height:auto; background-color : #fff;} #H-dialog. Close{float:right;font-size:30px;margin-right:10px;margin-top:5px;cursor:pointer;} #H-dialog title{height:40px;padding-left:10px; font-size:20px; line-height:40px;} #H-dialog #msgCont {height:36px; margin:30px 0 50px;padding-left:65px;font-size:25px;line-height:36px; Vertical-align:middle; Background:url (.. /images/ui_alert.png) no-repeat 20px 50%;} </style><div id= "H-dialog" > <a class= "Close" onclick= "Popupclose (This)" >x</a> <div class= "title" > Tips </div> <div id= "Msgcont" > Content </div></div><script type= "Text/javascript" > Lock background screen function lockscreen () {var clienth = document.body.offsetHeight;//body height var clientw = documen T.body.offsetwidth; Body width var doch = document.body.scrollHeight; Browser height var docw = document.body.scrollWidth; BrowseDevice width var BgW = clientw > DOCW? CLIENTW:DOCW; Take effective wide var BgH = clienth > doch? Clienth:doch; Take effective high var BLACKBG = document.createelement ("div"); Blackbg.id = "BLACKBG"; BlackBg.style.position = "absolute"; BlackBg.style.zIndex = "99999"; BlackBg.style.top = "0"; BlackBg.style.left = "0"; BlackBg.style.width = bgw+ "px"; BlackBg.style.height = bgh+ "px"; blackBg.style.opacity = "0.4"; BlackBg.style.backgroundColor = "#333"; Document.body.appendChild (BLACKBG); }//Close button event function Popupclose (EL) {var blackbg = document.getElementById ("BLACKBG"); BLACKBG && Document.body.removeChild (BLACKBG); El.parentNode.style.display = "None"; }//Auto-shutdown function autoClose (ID) {id = id | | "H-dialog"; var blackbg = document.getElementById ("BLACKBG"); var objdiv = document.getElementById (ID); SetTimeout (function () {BLACKBG&& Document.body.removeChild (BLACKBG); ObjDiv.style.display = "None"; },2000); }/** * Function: Popup information * Parameter 1: Message content * Parameter 2: Hint information status default 0 is prompt information, 1 is success information * Parameter 3: Popup div ID, default "h-dialog" * Parameter 4: Popup window Content ID , the default "Msgcont" **/function showmsg (msg) {msg = MSG | | "Please re-operate"; var status = arguments[1] | | 0, popupid = arguments[2] | | "H-dialog", contentId = arguments[3] | | "Msgcont"; Lockscreen (); Screen actual high width var pagewidth = window.innerwidth; var pageheight = window.innerheight; if (typeof pagewidth! = "Number") {if (Document.compatmode = = "Css1compat") {pagewidth = Docum Ent.documentElement.clientWidth; PageHeight = Document.documentElement.clientHeight; } else {pagewidth = Document.body.clientWidth; PageHeight = Document.body.clientHeight; }}//scroll bar high-width var scrollleft = window.documenT.documentelement.scrollleft; var scrolltop = 0; if (typeof window.pageyoffset! = ' undefined ') {scrolltop = Window.pageyoffset; } else if (typeof window.document.compatMode! = ' undefined ' && window.document.compatMode! = ' Backcompa T ') {scrolltop = Window.document.documentElement.scrollTop; } else if (typeof window.document.body! = ' undefined ') {scrolltop = Window.document.body.scrollTop; } var div_x = (pageWidth-400)/2 + scrollleft; var div_y = (pageHeight-200)/2 + scrolltop; var objdiv = document.getElementById (popupid); if (status) {document.getElementById (contentId). Style.background = "url ($Root/assets/images/ui_success.png) No -repeat 20px 50% "; } document.getElementById (contentId). InnerHTML = msg; ObjDiv.style.display = "block"; ObjDiv.style.left = div_x + "px"; ObjDiv.style.top = div_y + "px"; AutoClose (POPUPID); }</script>
Other wonderful articles
jquery Tutorial (-jquery) serialization form of AJAX operationsjquery Tutorial (-ajax) performing a POST request for Operationjquery Tutorial (-ajax) performing a GET request for data passing to the serverjquery Tutorial (-ajax) loading XML documents for Operationsjquery tutorial (-ajax) Execution script of the Operationjquery Tutorial (-ajax) manipulating JavaScript objects more about Android Development articles
JS Mask layer Popup box