弹出一个含有 确定、取消、重试三个按钮的对话框,并且得知用户的选择、请教一下大家、

解决方案 »

  1.   

    <!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>写了个小例子~·楼主看看
      

  2.   

    用模态对话框函数。
    在你这个页面里:
    <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变量并可以使用了。
      

  3.   

    或者可以使用现成的LIGHTBOX等JS插件。
      

  4.   

    window.open();
    也是可以的吧。。
      

  5.   

    模式方法能保证象ALERT的效果,你必须操作完它才能操作别的。而DIV层的方法和window.open()都没有这样的效果。
      

  6.   

    LIGHTBOX也是通过DIV层,但做了很多处理,实现类似模式对话框的效果。但作为JS题目的话,你直接用LIGHTBOX完成,显得有点取巧,出题者会觉得心不顺的,呵呵。
      

  7.   


    <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>
      

  8.   


    呵呵 ,我试了。能不能给点window.showModalDialog()这个函数的具体用法,我不是太懂,不过还是很谢谢你的答案,以前没用过,我很喜欢。