问答详情
源自:2-7 编程练习

无答案,求正解

无答案,求正解

提问者:刘妹妹 2015-07-20 11:18

个回答

  • 寒江北去
    2015-07-20 15:14:50

    <!DOCTYPE html>
    <html>
     <head>
      <title> new document </title>  
      <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>   
      <script type="text/javascript">  
    
        // 新窗口打开时弹出确认框,是否打开
        // 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
        function openWindow()
    	{
    		var userConfirm=confirm("是否打开");
    		if(userConfirm==true)
    		{
                var userPromote;
                userPromote=prompt("是否打开","www.imooc.com");
    			//打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
    			if (userPromote!=null)
    			{
    				window.open(userPromote,'_blank','width=400,height=500,menubar=no,toolbar=no');
    			}
                 else
                {
                    alert('用户点了取消按钮');
                }
    		}
            else
            {
                alert('用户点了取消按钮');
            }
    	}    
      </script> 
     </head> 
     <body> 
    	  <input type="button" value="新窗口打开网站" onclick="openWindow()" /> 
     </body>
    </html>


  • Perona
    2015-07-20 11:20:02

    可以参考下同学代码哦~~