程序在这儿~

来源:2-7 编程练习

Meredith_Grey

2016-03-29 20:34

<!DOCTYPE html>

<html>

 <head>

  <title> new document </title>  

  <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>   

  <script type="text/javascript">  

    function openWindow(){

    // 新窗口打开时弹出确认框,是否打开

    var taylor=confirm("确定打开窗口?");

    // 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/

    if(taylor==true){

        var swift=prompt("请输入网址:","http://www.imooc.com");

        if(swift!=null){

            window.open(swift,'_blank','width=400px,height=500px,menubar=no,toolbar=no');

        }else{

            alert("see you next time!");

        }

    

    }else{

        alert("ahaha");

    }

    }

    //打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。

    

    

  </script> 

 </head> 

 <body> 

 <input type="button" value="新窗口打开网站" onclick="openWindow()" /> 

 </body>

</html>


写回答 关注

4回答

  • 夜落雨
    2016-03-29 21:42:49
    <!DOCTYPE html>
    <html>
     <head>
      <title> new document </title>  
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>   
      <script type="text/javascript">  
        function openWinow(){
            var mymessage = confirm("确认打开窗口");
                if(mymessage == true){
                   var myurl = prompt("确认网址","http://www.imooc.com");
                    window.open(myurl,'_blank','width=400,height=500,menubar = no,toolbar = no');
                }
                else{
                    
                }
            }
            openWinow();  
      </script> 
     </head> 
     <body> 
    	  <input type="button" value="新窗口打开网站" onclick="openWindow()" /> 
     </body>
    </html>


  • gogo90hou
    2016-03-29 21:32:34

    同上............

  • yclycl
    2016-03-29 21:32:25

    30秒

  • 朱麦迪
    2016-03-29 21:25:50

    var swift=prompt("请输入网址:""http://www.imooc.com");
    这一行参数间的逗号是中文字符,找了好久才发现。。。。

JavaScript入门篇

JavaScript做为一名Web工程师的必备技术,本教程让您快速入门

742055 学习 · 9869 问题

查看课程

相似问题