<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style>
*{margin:0;padding:0;}
#div_1{font-size:12px;padding:6px 0 0 10px;}
#div_2{border:1px solid #000;width:300px;height:150px;background:#CCCCCC;position:absolute;left:50%;top:50%;margin-left:-150px;margin-top:-75px;display:none;}
#div_2 p{height:20px;font-size:12px;padding:5px 0 0 5px;font-weight:bold;border-bottom:1px solid #000;}
#close{width:14px;height:14px;position:absolute;right:2px;top:2px;font-size:11px;}
</style>
<script>
window.onload=function(){
var divone=document.getElementById('div1');
var divtwo=document.getElementById('div2');
var bt=document.getElementById('bt');
var clo=document.getElementById('close');
function addEvent(ele,type,hander){
if(ele.addEventListener){
ele.addEventListener(type,hander,false);
}
else if(ele.attachEvent){
ele.attachEvent('on'+type,hander);
}
else{
ele['on'+type]=hander;
}
}
function displayA(){
divtwo.style.display='block';
}
function cancel(){
divtwo.style.display='none';
}
addEvent(bt,'click',displayA);
addEvent(clo,'click',cancel);
}
</script>
</head>
<body>
<div id="div_1">
亲,请登录<input type="button" value="登录" id="bt"/>
</div>
<div id="div_2">
<p>用户登录</p><span id="close">关闭</span>
</div>
</body>
</html>
var divone=document.getElementById('div1') 改为div_1;
var divone=document.getElementById('div2');改为div_2