利用js对象弹出一个层
利用js对象弹出一个层
发布时间:2016-12-30 来源:查字典编辑
摘要:复制代码代码如下:查字典教程网-弹出一个层functioncmsgbox(vtitle,vwidth,vhight,vtop,vleft){...

复制代码 代码如下:

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<head>

<metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>

<title>查字典教程网-弹出一个层</title>

<scriptlanguage="javascript">

functioncmsgbox(vtitle,vwidth,vhight,vtop,vleft)

{

this.title=vtitle;

this.width=vwidth;

this.height=vhight;

this.top=vtop;

this.left=vleft;

this.id=0;

}

cmsgbox.prototype.showdiv=function()

{

varstr="";

str+="<divid='div1'style='z-index:1;background-color:white;position:absolute;border:2pxsolidslategray;left:"+this.vleft+"px;top:"+this.vtop+"px;width:"+this.width+"px;'>";

str+="<divstyle='padding-bottom:2px;background-color:slategray;width:100%;height:16px;color:white;'>";

str+="<divstyle='float:left;height:16px;overflow:hidden;margin:0px;padding:4px0px0px5px;width:"+(parseInt(this.width)-24*2-5)+"px;'>"+this.title+"</div>";

str+="<spanstyle='width:14px;font-family:webdings;cursor:hand;'>0</span>";

str+="<spanstyle='width:14px;font-family:webdings;cursor:hand;'onclick='cmsgbox.closediv(this);'>r</span>";

str+="</div>";

str+="<divstyle='margin:10px5px10px10px;word-break:break-all;'>";

str+="xxx";

str+="</div>";

str+="</div>";

//document.write(str);

document.body.insertAdjacentHTML("beforeEnd",str);

}

/////////////////////窗口显示//////////////////////////////

functionshow()

{

varbox=newcmsgbox('小家伙呀',400,300);

box.showdiv();

}

</script>

</head>

<style>

body{

font-size:12px;

}

</style>

<body>

<ponclick="show();">弹了一个层</p>

</body>

</html>

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新Javascript教程学习
热门Javascript教程学习
编程开发子分类