帮忙解释一下这段javascript

来源:百度知道 编辑:UC知道 时间:2024/06/07 22:44:45
function createDiv(){
var msgObj=document.createElement("div")
msgObj.setAttribute("id","msgDiv");
msgObj.setAttribute("align","center");
msgObj.style.background="white";
msgObj.style.border="1px solid #0000FF";
msgObj.style.position = "absolute";
msgObj.style.left = "55%";
msgObj.style.top = "50%";
msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
msgObj.style.marginLeft = "-225px" ;
msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
msgObj.style.width = 300 + "px";
msgObj.style.height =120 + "px";
msgObj.style.textAlign = "center";
msgObj.style.lineHeight ="25px";

可以考虑去看一下HTMLDOM对象。
http://www.w3school.com.cn/htmldom/index.asp
对于你理解这段代码有好处。

建立一个对话框,对话框里面有个按钮 “确定”

var msgObj=document.createElement("div")建立一个div
msgObj.setAttribute("id","msgDiv");div的id=msdDiv
msgObj.setAttribute("align","center");内容居中显示align=center
msgObj.style.background="white";同上
msgObj.style.border="1px solid #0000FF";
msgObj.style.position = "absolute";
msgObj.style.left = "55%";
msgObj.style.top = "50%";
msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
msgObj.style.marginLeft = "-225px" ;
msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
msgObj.style.width = 300 + "px";
msgObj.style.height =120 + "px&qu