码迷,mamicode.com
首页 > Windows程序 > 详细

js——window.open用法

时间:2017-07-22 09:40:55      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:oct   asc   结合   tle   function   content   default   conf   div   

今天在慕课网上接触了下javaScript的基础。以下是结合运用了confirm(),prompt(),open()的小例子。

1. confirm(message);

    参数说明:

  message:在消息对话框中要显示的文本
  返回值: Boolean值

    返回值:

  当用户点击"确定"按钮时,返回true
  当用户点击"取消"按钮时,返回false

2. prompt(text,defaultText);

    参数说明:

  text: 要显示在消息对话框中的文本,不可修改 
  defaultText:文本框中的内容,可以修改

    返回值:

  1. 点击确定按钮,文本框中的内容将作为函数返回值
  2. 点击取消按钮,将返回null

3.window.open([URL], [窗口名称], [参数字符串])

技术分享

 1 <!DOCTYPE HTML>
 2 <html>
 3     <head>
 4     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5     <title>window.open</title>
 6     <script type="text/javascript">
 7       function Wopen(){
 8           var whetherOpen = confirm("要不要去新世界?"); 
 9           if (whetherOpen == true) {
10               var url = prompt("输入您想去嘿嘿的网址");  //文本框中输入的内容返回存放在url中
11               window.open(url,‘_blank‘,‘width=600,height=400,top=100,left=0‘);  //将url传入,选择新建窗口打开
12           }else{
13               alert("不想去那你瞎点什么,滚!");
14           }
15       }
16     </script>
17     </head>
18     <body>
19         <input name="button" type="button" onClick="Wopen()" value="别说话,先点我!" / >
20     </body>
21 </html>

注意:网址都要以http://开始

技术分享

技术分享

 

js——window.open用法

标签:oct   asc   结合   tle   function   content   default   conf   div   

原文地址:http://www.cnblogs.com/xiechenwen/p/7220182.html

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