javascript题目 弹出一个含有 确定、取消、重试三个按钮的对话框,并且得知用户的选择、请教一下大家、 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <!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=utf-8" /><title>无标题文档</title><style> .d{ position:absolute; left:200px; top:200px; z-index:1; width:200px; height:40px; border:1px solid #000; text-align:center; padding-top:180px; display:none; } </style></head><body> <div id="d" class="d"> <input type="button" value="确定" /> <input type="button" value="取消" /> <input type="button" value="重试" /> </div> <input type="button" value="显示" id="btn" /> <script type="text/javascript"> document.getElementById('btn').onclick = function(){ document.getElementById('d').style.display = 'block'; }; var inps = document.getElementById('d').getElementsByTagName('input'), len = inps.length; for(var i = 0; i < len; i++){ !function(i){ inps[i].onclick = function(){ alert(this.value); }; }(i) } </script></body></html>写了个小例子~·楼主看看 用模态对话框函数。在你这个页面里:<script> var theforever_csdn =window.showModalDialog("theforever_csdn.htm",,"dialogWidth=200px;dialogHeight=100px"); alert(theforever_csdn);</script> 另外写个theforever_csdn.htm,内容是那几个按钮,并设置它们的点击事件(在事件里给window.returnValue赋值为相应的值:确定/取消/重试,并执行window.close()。这样,弹出theforever_csdn.htm之后,点击选择后,结果就传回给父页面的JS变量并可以使用了。 或者可以使用现成的LIGHTBOX等JS插件。 window.open();也是可以的吧。。 模式方法能保证象ALERT的效果,你必须操作完它才能操作别的。而DIV层的方法和window.open()都没有这样的效果。 LIGHTBOX也是通过DIV层,但做了很多处理,实现类似模式对话框的效果。但作为JS题目的话,你直接用LIGHTBOX完成,显得有点取巧,出题者会觉得心不顺的,呵呵。 <head runat="server"> <title>无标题页</title> <style> .d{ position:absolute; left:200px; top:200px; z-index:1; width:200px; height:40px; border:1px solid #000; text-align:center; padding-top:180px; display:none; } </style> <script type="text/javascript"> </script> </head><body> <div id="d" class="d"> <input type="button" value="确定" /> <input type="button" value="取消" /> <input type="button" value="重试" /> </div> <input type="button" value="显示" id="btn" /> <script type="text/javascript"> document.getElementById("btn").onclick=function(){ document.getElementById("d").style.display="block"; } var div=document.getElementById("d"); for(var m=div.firstChild;m!=null;m=m.nextSibling) { if( m.nodeType==1) m.onclick=function(){alert(this.value);} } </script> </body> 呵呵 ,我试了。能不能给点window.showModalDialog()这个函数的具体用法,我不是太懂,不过还是很谢谢你的答案,以前没用过,我很喜欢。 EXT gridPanel 表头不出现问题 一段JavaScript代码问题 请教个定义函数对象的问题 怎样实时显示操作信息 这段操作cookie的代码哪里错了啊? 一个关于keycode的问题 如果有空看一下,谢谢 <textarea>中的文本(带有换行)用程序PasteSpecial粘帖到word中,没有了换行?谢谢!!! 请教Html(xml)中的Node问题 怎样用纯脚本语言在客户端,实现树状结构资源管理,谢谢 jQuery 异步加载问题 js如何访问在函数体内动态创建的标签!!!
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
.d{
position:absolute;
left:200px;
top:200px;
z-index:1;
width:200px;
height:40px;
border:1px solid #000;
text-align:center;
padding-top:180px;
display:none;
} </style>
</head><body>
<div id="d" class="d">
<input type="button" value="确定" />
<input type="button" value="取消" />
<input type="button" value="重试" />
</div>
<input type="button" value="显示" id="btn" />
<script type="text/javascript">
document.getElementById('btn').onclick = function(){
document.getElementById('d').style.display = 'block';
};
var inps = document.getElementById('d').getElementsByTagName('input'),
len = inps.length;
for(var i = 0; i < len; i++){
!function(i){
inps[i].onclick = function(){
alert(this.value);
};
}(i)
}
</script>
</body>
</html>写了个小例子~·楼主看看
在你这个页面里:
<script>
var theforever_csdn =window.showModalDialog("theforever_csdn.htm",,"dialogWidth=200px;dialogHeight=100px");
alert(theforever_csdn);
</script> 另外写个theforever_csdn.htm,内容是那几个按钮,并设置它们的点击事件(在事件里给window.returnValue赋值为相应的值:确定/取消/重试,并执行window.close()。这样,弹出theforever_csdn.htm之后,点击选择后,结果就传回给父页面的JS变量并可以使用了。
也是可以的吧。。
<head runat="server">
<title>无标题页</title>
<style>
.d{
position:absolute;
left:200px;
top:200px;
z-index:1;
width:200px;
height:40px;
border:1px solid #000;
text-align:center;
padding-top:180px;
display:none;
} </style>
<script type="text/javascript"> </script>
</head>
<body>
<div id="d" class="d">
<input type="button" value="确定" />
<input type="button" value="取消" />
<input type="button" value="重试" />
</div>
<input type="button" value="显示" id="btn" />
<script type="text/javascript">
document.getElementById("btn").onclick=function(){
document.getElementById("d").style.display="block";
}
var div=document.getElementById("d");
for(var m=div.firstChild;m!=null;m=m.nextSibling)
{
if( m.nodeType==1) m.onclick=function(){alert(this.value);}
}
</script>
</body>
呵呵 ,我试了。能不能给点window.showModalDialog()这个函数的具体用法,我不是太懂,不过还是很谢谢你的答案,以前没用过,我很喜欢。