利用js對象彈出一個(gè)層
更新時(shí)間:2008年03月26日 21:43:03 作者:
用js實(shí)現(xiàn)彈出層效果,一般用于代替alert
復(fù)制代碼 代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>腳本之家-彈出一個(gè)層</title>
<script language="javascript">
function cmsgbox(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()
{
var str="";
str+="<div id='div1' style='z-index:1;background-color:white;position:absolute;border:2px solid slategray;left:"+this.vleft+"px;top:"+this.vtop+"px;width:"+this.width+"px;'>";
str+="<div style='padding-bottom:2px;background-color:slategray;width:100%;height:16px;color:white;' >";
str+=" <div style='float:left;height:16px;overflow:hidden;margin:0px;padding:4px 0px 0px 5px;width:"+(parseInt(this.width)-24*2-5)+"px;'>"+this.title+"</div>";
str+=" <span style='width:14px;font-family:webdings;cursor:hand;'>0</span>";
str+=" <span style='width:14px;font-family:webdings;cursor:hand;' onclick='cmsgbox.closediv(this);'>r</span>";
str+="</div>";
str+="<div style=' margin:10px 5px 10px 10px;word-break:break-all;'>";
str+="xxx";
str+="</div>";
str+="</div>";
//document.write(str);
document.body.insertAdjacentHTML("beforeEnd",str);
}
/////////////////////窗口顯示//////////////////////////////
function show()
{
var box=new cmsgbox('小家伙呀',400,300);
box.showdiv();
}
</script>
</head>
<style>
body{
font-size:12px;
}
</style>
<body>
<p onclick="show();">彈了一個(gè)層</p>
</body>
</html>
相關(guān)文章
javascript過濾數(shù)組重復(fù)元素的實(shí)現(xiàn)方法
這篇文章主要介紹了javascript過濾數(shù)組重復(fù)元素的實(shí)現(xiàn)方法的相關(guān)資料,需要的朋友可以參考下2017-05-05
Bootstrap打造一個(gè)左側(cè)折疊菜單的系統(tǒng)模板(一)
這篇文章主要介紹了Bootstrap打造一個(gè)左側(cè)折疊菜單的系統(tǒng)模板(一)的相關(guān)資料,需要的朋友可以參考下2016-05-05
JS實(shí)現(xiàn)的網(wǎng)頁背景閃電閃爍效果代碼
這篇文章主要介紹了JS實(shí)現(xiàn)的網(wǎng)頁背景閃電閃爍效果代碼,涉及JavaScript定時(shí)函數(shù)結(jié)合頁面元素樣式操作的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-10-10
javascript正則表達(dá)式中的replace方法詳解
replace方法的語法是:stringObj.replace(rgExp, replaceText) 其中stringObj是字符串(string),reExp可以是正則表達(dá)式對象(RegExp)也可以是字符串(string),replaceText是替代查找到的字符串。。2015-04-04

