首页 > 编程语言 > 详细

javascript操作css实现弹出对话框

时间:2015-10-12 00:39:15      阅读:266      评论:0      收藏:0      [点我收藏+]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function ss(){
var div=document.createElement("div");
var textarea=document.createElement("textarea");

var button=document.createElement("input");
button.type=‘button‘;
button.value=‘OK‘;
button.onclick=function(){
document.getElementById("show").value=textarea.value;
document.body.removeChild(button);
document.body.removeChild(textarea);
document.body.removeChild(div);
}
setStyle(div,{
‘position‘:‘absolute‘,
‘left‘:0,
‘top‘:0,
‘bottom‘:0,
‘right‘:0,
‘backgroundColor‘:‘black‘,
‘opacity‘:.5,
‘filter‘:‘alpha(opacity=50)‘
});
setStyle(button,{
‘position‘:‘absolute‘,
‘left‘:‘250px‘,
‘top‘:‘160px‘
})
setStyle(textarea,{
‘position‘:‘absolute‘,
‘left‘:‘100px‘,
‘top‘:‘100px‘
})
document.body.appendChild(div);
document.body.appendChild(button);
document.body.appendChild(textarea);


}
function setStyle(dom,style){
for(var i in style){
if(style.hasOwnProperty(i)){
dom.style[i]=style[i];
}
}
}
</script>
</head>

<body>
<input type="text" id="show" />
<input type="button" value="输入" onclick="ss()">
</body>
</html>

 

 

 

效果:技术分享

 

 

 

 

技术分享

技术分享

javascript操作css实现弹出对话框

原文:http://www.cnblogs.com/jiangwenli/p/4870391.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!