zoukankan      html  css  js  c++  java
  • confirg

     如果用户点击确定按钮,则 confirm() 返回 true。如果点击取消按钮,则 confirm() 返回 false。
    在用户点击确定按钮或取消按钮把对话框关闭之前,它将阻止用户对浏览器的所有输入。在调用 confirm() 时,将暂停对 JavaScript 代码的执行,在用户作出响应之前,不会执行下一条语句。
    下面我们通过这两个小例子,来了解一下它的使用方法吧:
    复制代码 代码如下:

    <html>
    <head>
    <title>confrim 的使用方法</title>
    <script type="text/javascript">
    function clear1()
    {
     if(confirm("确定要清空数据吗?"))
     {
     document.main.text1.value="";
     }
    }
    </script>
    </head>
    <boty>
    <form name="main">
    <input type="text" name="text1"/>
    <input type="button" name="submit" value="数据清空" onclick="return clear1()"/>
    </form>
    </body>
    <ml>
    <html>
    <head>
    <title>js confirm</title>
    <script>
    function begin()
    {
     var a=confirm("郭杨和小代是好朋友吗?");
     if(a==true)
     {
     /*document.write("恭喜你答对了!");*/
     alert("恭喜你答对了!");
     begin();
     }
     else
     {
     /*document.write("你真是猪,这么简单的问题都答不对!");*/
     alert("你真是猪,这么简单的问题都答不对!");
     begin();
     }
     }
    </script>
    </head >
    <body onload="begin()">
    </body>
    <ml>
  • 相关阅读:
    shell脚本编程-重定向
    web安全-剖析_基础构架剖析
    shell脚本编程-函数
    shell脚本编程-循环
    web安全-入侵基础
    shell脚本编程-检查和测试
    shell脚本编程-特殊字符
    shell脚本编程-计算方式
    python例子-抓取网站IP列表
    linux问题-APR not Found
  • 原文地址:https://www.cnblogs.com/kongxc/p/7110530.html
Copyright © 2011-2022 走看看