Javascript 代码:【复制】var clientWidth = window.innerWidth /*W3C*/ || document.documentElement.clientWidth /*std IE*/ || document.body.clientWidth/*IE quirk mode*/; var clientHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; function makeMASK() { var maskDIV = document.createElement('div'); maskDIV.id = 'DIV_MASK'; maskDIV.style.position = 'absolute'; maskDIV.style.filter = 'Alpha(Opacity=30)'; maskDIV.style.opacity = 0.3; maskDIV.style.backgroundColor = '#000000'; maskDIV.style.width = '100%'; //maskDIV.style.height = window.document.documentElement.scrollHeight + 'px'; maskDIV.style.height = clientHeight + 'px'; if(clientHeight < window.document.documentElement.scrollHeight) { maskDIV.style.height = window.document.documentElement.scrollHeight + 'px'; } maskDIV.style.top = '0px'; maskDIV.style.left = '0px'; maskDIV.style.zIndex = '1000'; document.body.appendChild(maskDIV); } function maskDIVClose() { var mDIV = document.getElementById('DIV_MASK'); if (mDIV) { document.body.removeChild(mDIV); } } function ShowDIV(divID,divTitle,divConType,divContent,dWidth,dHeight) { makeMASK(); var iDiv = document.createElement('div');//虚拟一个DIV var divHeader = document.createElement('div'); divHeader.id = divID+'_Header'; if(divConType == 'URL') { if(navigator.userAgent.indexOf('MSIE') === -1) { var divBody = document.createElement('iframe'); } else { var divBody = document.createElement('<iframe frameborder="0"></iframe>'); } } else { var divBody = document.createElement('div'); } divBody.id = divID+'_Body'; iDiv.appendChild(divHeader); iDiv.appendChild(divBody); document.body.appendChild(iDiv); iDiv.id = divID; iDiv.style.position = 'fixed'; iDiv.style.width = dWidth+'px'; iDiv.style.zIndex = '1001'; iDiv.style.border = '1px solid #8A0B00'; iDiv.style.backgroundColor = '#ffffff'; divHeader.innerHTML = '<div class="CSS_divHeader"><span style="float:left;">■ '+divTitle+'</span><span style="float:right;cursor:pointer;font-size:16px;" onclick="CloseDIV(\''+divID+'\')" title="关闭">×</span></div>'; if(divConType == 'URL') { divBody.src = divContent; divBody.frameBorder = 0; divBody.width = '100%'; divBody.height = dHeight; //divBody.style.hspace = '3px'; //divBody.setAttribute('frameborder', '0', 0); } else { divBody.innerHTML = '<div class="CSS_divBody">'+divContent+'</div>'; divBody.style.height = dHeight+'px'; divBody.style.overflow = 'auto'; } iDiv.style.top = Math.round((clientHeight - divBody.offsetHeight) / 2) + 'px'; iDiv.style.left = Math.round((clientWidth - iDiv.offsetWidth) / 2) + 'px'; return iDiv; } function CloseDIV(nDIV) { var nDIV = document.getElementById(nDIV); if (nDIV) { document.body.removeChild(nDIV); } maskDIVClose(); }