码迷,mamicode.com
首页 > 编程语言 > 详细

Javascript 基础编程练习一

时间:2016-02-18 06:30:05      阅读:272      评论:0      收藏:0      [点我收藏+]

标签:

Javascript 基础互动编程,这篇练习结合了function 函数名(), onclick 时间, prompt输入窗口, window.open和confirm窗口,

任务

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

提示: 使用 if 判断确认框是否点击了确定,如点击弹出输入对话框,否则没有任何操作。

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

3、打开的窗口要求,宽800像素,高600像素,无菜单栏、无工具栏。

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4     <title> new document </title>
 5     <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
 6     <script type="text/javascript">
 7         function openWindow(){
 8             var mycon=confirm("请问你是否要打开");// 新窗口打开时弹出确认框,是否打开
 9             if(mycon==true){
10                 var mypro=prompt("请输入你要打开的网址");// 通过输入对话框,确定打开的网址,默认为 http://www.cnblogs.com/
11                 if(mypro!=null){
12                     window.open(mypro,"_blank","width=800,height=600,menubar=no,toolbar=no");
13                 }else{
14                     window.open("http://www.cnblogs.com/","_blank","width=800,height=600,menubar=no,toolbar=no");
15                     //打开的窗口要求,宽800像素,高600像素,无菜单栏、无工具栏。
16                 }
17             }
18         }
19     </script>
20 </head>
21 <body>
22 <input type="button" value="新窗口打开网站" onclick="openWindow()" />
23 </body>
24 </html>

 

Javascript 基础编程练习一

标签:

原文地址:http://www.cnblogs.com/bear070913/p/5196974.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!