IE FF OPERA都可用的弹出层实现代码_javascript技巧
程序员文章站
2022-04-28 08:05:34
...
复制代码 代码如下:
// JavaScript Document
var dv;
var dvMsg;
function customalert()
{
dvMsg = document.createElement("div");
dvMsg.style.position = "absolute";
dvMsg.setAttribute('id', 'msg');
dvMsg.style.width = "600px";
dvMsg.style.padding = "10 0 2 0";
dvMsg.style.height = "313px";
dvMsg.style.background = "#EF621D";
dvMsg.style.border = "1px solid #6699dd";
dvMsg.style.zIndex = "1112";
document.body.appendChild(dvMsg);
document.getElementById("msg").style.top = document.documentElement.scrollTop + (document.documentElement.clientHeight - document.getElementById("msg").offsetHeight)/2 + "px";
document.getElementById("msg").style.left = document.documentElement.scrollLeft + (document.documentElement.clientWidth - document.getElementById("msg").offsetWidth)/2 + "px";
var imgs = document.createElement("div");
imgs.setAttribute("id", "pic");
imgs.title = "close";
imgs.style.float = "left";
imgs.style.height = "20px";
imgs.innerHTML = "";
imgs.style.color = "#FFF";
imgs.style.textAlign = "right";
imgs.style.cursor = "pointer";
imgs.style.zIndex = "1114";
imgs.onclick = function()
{
document.body.removeChild(dvMsg);
document.body.removeChild(dv);
}
document.getElementById("msg").appendChild(imgs);
var divstr = document.createElement("div");
divstr.setAttribute("id", "info");
divstr.style.left = "0";
divstr.style.position = "absolute";
divstr.style.marginTop = "10px";
divstr.style.zIndex = "1115";
divstr.innerHTML = "";
document.getElementById("msg").appendChild(divstr);
}
function scrolldivs()
{
document.getElementById("msg").style.top=document.documentElement.scrollTop+(document.documentElement.clientHeight-document.getElementById("msg").offsetHeight)/2+"px";
document.getElementById("msg").style.left=document.documentElement.scrollLeft+(document.documentElement.clientWidth-document.getElementById("msg").offsetWidth)/2+"px";
}
window.attachEvent("onresize",scrolldivs);
window.onscroll=scrolldivs;
window.onload=scrolldivs;
上一篇: JavaScript中的函数(二)_javascript技巧
下一篇: php实现中文转数字_PHP
推荐阅读
-
js实现的真正的iframe高度自适应(兼容IE,FF,Opera)_javascript技巧
-
js实现的真正的iframe高度自适应(兼容IE,FF,Opera)_javascript技巧
-
JS实现新浪微博效果带遮罩层的弹出框代码_javascript技巧
-
IE FF OPERA都可用的弹出层实现代码_javascript技巧
-
js实现可兼容IE、FF、Chrome、Opera及Safari的音乐播放器_javascript技巧
-
JS实现新浪微博效果带遮罩层的弹出框代码_javascript技巧
-
代码短小的js div层拖动实现代码[兼容IE与Firefox]_javascript技巧
-
js实现可兼容IE、FF、Chrome、Opera及Safari的音乐播放器_javascript技巧
-
IE FF OPERA都可用的弹出层实现代码_javascript技巧
-
代码短小的js div层拖动实现代码[兼容IE与Firefox]_javascript技巧