小九九学前端随记16

javaScript 函数
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>函数调用</title>
   <script type="text/javascript">
      function aa() //定义函数
      {
         alert("第一次调用函数。");
      }
   </script>
</head>
<body>
   <form>
      <input type="button"  value="点击" οnclick=" aa()" />  
   </form>
</body>
</html>
confirm对话框

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

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>confirm</title>
  <script type="text/javascript">
  function aa(){
    var mymessage=true;
    while(mymessage){
        if(confirm("你是猪吗?"))
        {
            alert("Oh god, you are a pig!");
            var mymessage=false;
        }
        else
        {
            alert("Are you sure?")
        }
    }
  }    
  </script>
</head>
<body>
    <input name="button" type="button" onClick="aa()" value="点击我,弹出确认对话框" />
</body>
</html>
prompt对话框

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

打开新窗口
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>window.open</title>
<script type="text/javascript">
  function Wopen(){
    window.open('http://www.baidu.com','aa','width=800,height=800,menubar=no,toolbar=no, status=no,scrollbars=yes')
  } 
</script>
</head>
<body>
    <input name="button" type="button" onClick="Wopen()" value="点击我,打开新窗口!" / >
</body>
</html>






  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值