IE FF OPERA都可用的弹出层实现代码
作者:bea
代码如下: // 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
代码如下:
// 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 = "<a href="http://" target="_blank"><img src="../javascript/close.gif"/></a>";
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 = "<embed src="gallery/header2.swf" pluginspage="http://www.macromedia.com/shockwave/download /" width="600" height="313"></embed>";
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 浮点数运算 精度问题
- 面向对象的javascript(笔记)
- js removeChild 障眼法 可能出现的错误
- 学习JS面向对象成果 借国庆发布个最新作品与大家交流
- JQuery与Ajax常用代码实现对比
- Jquery 设置标题的自动翻转
- jQuery animate效果演示
- JavaScript CSS 通用循环滚动条
- 签名框(Textarea)限制文字数量并适时提示
- 点击下载链接 弹出页面实现代码
- 点击文章内容处弹出页面代码
- js类的静态属性和实例属性的理解
- XmlUtils JS操作XML工具类
- 点击按钮后 文本框变为Select下拉列表框
- JavaScript 自动在表格前面增加序号
- PPK 谈 JavaScript 的 this 关键字 [翻译]
- 一个JS小玩意 几个属性相加不能超过一个特定值.
- javascript String split方法误操作