JS 隐藏显示DIV 我想实现的功能:通过JS,点击一个按钮自动弹出一个DIV在显示器的中央,里面的内容写“请稍后”并且这个页面的所有信息都不能被点击过了3秒,DIV自动关闭哪位知道怎么写的帮我解决下 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用模态窗口模拟一个,不一定非得要div window.showModalDialog(sURL[,vArguments][,sFeatures]); 一个模态窗体,当然页面内容可以自己随便写,然后 setTimeout()3秒之后,window.close()。~ <!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>无标题文档</title><script type="text/javascript"> function test(){ divTest.innerHTML ="请稍后..."; setTimeout('hideMethod()',3000); } function hideMethod(){ divTest.style.display="none"; }</script></head><body><form id="form1" method="post"> <input type="button" onclick="test()" value="测试" /></form><div id="divTest" style="background-color:red"></div></body></html>直接考下来可以测试! 3楼的要是select话,还是可以选的 3楼的可以。思路就是将一个透明的div覆盖住整个屏幕,在中间加入想要的文字。 楼主你要明白原理,首先你点击的时候要弹出层,还要显示三秒,所以,首先你写一个层,当点击的时候要显示出来,写一个定时器,单秒后要hide 我的意思没表明清楚我是想单击一个按钮后,显示出一个小的DIV在屏幕的中央过3秒后自动隐藏 <!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>无标题文档</title><style type="text/css"> .mystyle {position:absolute; top:50%; left:50%; text-align:center; margin:-100px 0 0 -100px; width:200px; height:100px; /*这里,height和line-height的值设置成一样,使文字垂直居中显示在DIV当中*/ line-height:100px; background:#000 ; FILTER: progid:DXImageTransform.Microsoft.Gradient(startColorStr='#ffffff', endColorStr='#00009B', gradientType='0'); }</style><div></div><script type="text/javascript"> function test(){ document.getElementById("divTest").className="mystyle"; divTest.innerHTML ="请稍后......"; setTimeout('hideMethod()',3000); } function hideMethod(){ divTest.style.display="none"; }</script></head><body><form id="form1" method="post"> <input type="button" onclick="test()" value="测试" /></form><div id="divTest"></div></body></html>其实这些问题,给你了一个样式,自己调下就可以得到你想要的结果的 给楼主个思路:用两层的div最外层的铺满整个屏幕,但是隐藏,里面的div用于显示你的提示信息,居中。3楼的代码大致实现了这个功能,但还是可以点击其他的,也就是不是模态的!还有就是在点击之前是隐藏的,点击之后再显示! 最好是用两个DIV做,这样子灵活性大。 用两个div,和三楼的思路差不多, 一个div做mask,一个用来显示信息。 我之前做的一个效果,这里不能上传图片,我截了图放在百度空间http://hi.baidu.com/liguocan/album/item/49e41838eea85c14b9998fd2.html你看下效果。无论窗口大小怎么改变,滚动条滚到什么地方,“消息”都会居中显示。这个示例中不是弹出的消息,而是一个登录表单,在我提供的js中有示例,轻松控制其中显示的内容,可以使消息。至于定时消失的问题,我没做,这个应该超级简单,你写个定时函数,到3s就调用win.hide();待会上传代码 代码上传到http://www.dbank.com/download.action?t=40&k=Mzc5NDIzNA==&pcode=LCw0NTEyMiw0NTEyMg==&rnd=9763 把值返回给select·· javascript在html页面不执行,为什么呀 jquery ui tabs 有点问题 论坛怎样上传附件? 比较两个时间大小 请大家来帮忙看一段代码,关于html:select的,onchange方法没法激活 一个简单的css问题 100分 如何判断一个对象是有效的 如何通过哑链接使播放器改变播放文件? 怎么格式化一个10以内的数字,在它前面加上0,比如1变成01,2变成02 求一js,网页中的元素可以添加和位置任意移动 Js 编码问题
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function test(){
divTest.innerHTML ="请稍后...";
setTimeout('hideMethod()',3000);
}
function hideMethod(){
divTest.style.display="none";
}
</script>
</head><body>
<form id="form1" method="post">
<input type="button" onclick="test()" value="测试" />
</form>
<div id="divTest" style="background-color:red"></div>
</body>
</html>直接考下来可以测试!
我是想单击一个按钮后,显示出一个小的DIV在屏幕的中央
过3秒后自动隐藏
<!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>无标题文档</title>
<style type="text/css">
.mystyle
{position:absolute;
top:50%;
left:50%;
text-align:center;
margin:-100px 0 0 -100px;
width:200px;
height:100px; /*这里,height和line-height的值设置成一样,使文字垂直居中显示在DIV当中*/
line-height:100px;
background:#000 ;
FILTER: progid:DXImageTransform.Microsoft.Gradient(startColorStr='#ffffff', endColorStr='#00009B', gradientType='0');
}
</style>
<div></div>
<script type="text/javascript">
function test(){
document.getElementById("divTest").className="mystyle";
divTest.innerHTML ="请稍后......";
setTimeout('hideMethod()',3000);
}
function hideMethod(){
divTest.style.display="none";
}
</script>
</head><body>
<form id="form1" method="post">
<input type="button" onclick="test()" value="测试" />
</form>
<div id="divTest"></div>
</body>
</html>
其实这些问题,给你了一个样式,自己调下就可以得到你想要的结果的
3楼的代码大致实现了这个功能,但还是可以点击其他的,也就是不是模态的!还有就是在点击之前是隐藏的,点击之后再显示!
你看下效果。无论窗口大小怎么改变,滚动条滚到什么地方,“消息”都会居中显示。
这个示例中不是弹出的消息,而是一个登录表单,在我提供的js中有示例,轻松控制其中显示的内容,可以使消息。至于定时消失的问题,我没做,这个应该超级简单,你写个定时函数,到3s就调用win.hide();
待会上传代码