怎么让alert输出input,这样的html元素?
alert();不能指定标题?
高手指点下,谢谢!

解决方案 »

  1.   

    alert是完成不了你说的功能的,你说的功能可以使用window.showModalDialog
      

  2.   

    <input id="i" value="abc" /><input type="button" value="Click me" onclick="alert(i.value)"/>alert不能指定标题,可以用vbscript的MsgBox,它能指定标题。
      

  3.   

    可以用DIV模拟呀,第一行放标题,下面放内容
      

  4.   

    给你一个例子, 两年前写的,代码有点乱<html>
        <head>
        <title>test div</title>
        <style>
                #dlg{
                        height: 200px;
                        width: 350px;
                        border: solid black 1px;
                }
                td{
                        padding: 5px;
                }
        </style>
        <style type="text/css">
            
        </style>
        <script language="javascript">
            function showDialog(){
                var masklayer = document.all("mask") ;
                masklayer.style.width = screen.width ;
                masklayer.style.height = screen.height ;
                masklayer.style.display = "" ;
                var dlg = document.getElementById("dlg");
                dlg.style.display = "";
            }
            function hideDialog(){
                var masklayer = document.all("mask") ;
                masklayer.style.display = "none" ;
                var dlg = document.getElementById("dlg");
                dlg.style.display = "none";
            }
        function doEscape(){
            var masklayer = document.all("mask") ;
            var dlg = document.getElementById("dlg") ;
            if(masklayer.style.display==""||mask.style.display==""){
                if (event.ctrlKey){
                    alert("event.key") ;
                }
            }
        }
        </script>
        <body>
            <input type="submit" value="Show dialog" onClick="showDialog();">
            <div id="mask" name="mask" style="position:absolute;left:0px;top:0px;display:none;z-index:999;filter:alpha(opacity=40);background-color:silver"></div>
            <div id="dlg"  onkeydown="doEscape();" name="dlg" style="position:absolute;display:none;left:380px;top:250px;z-index:1000;border:1px;border-color:red">
            <table border=1 height="200" width="350" aligh="center" style="border-collapse:collapse;background-color:#eeeeee;"><tr><td>This is a customer dialog</td></tr><tr><td>
            <input type="submit" value="Close dialog" onClick="hideDialog();"></td></tr><tr><td></td></tr></table></div>
        </body>
    </html>