zoukankan      html  css  js  c++  java
  • Javascript 中的事件

    事件,一旦离开鼠标

    <!DOCTYPE html>
    <html>
    <head>
        <script type="text/javascript">
            function checkPassword(object)
            {
                if(object.value.length <=4)
                {
                    alert("密码长度过短。");
                    object.focus(); //选中对象
                    object.select(); //选中全部内容
                }
            }
        </script>
    
    </head>
    
    <body>
        密码: <input type = "password" onblur="checkPassword(this);">
        
    </body>
    </html>

    onlbur:一旦焦点离开,就调用 checkPassword(this)。this 表示当前对象。

    Javascript, 无类有对象。

    <!DOCTYPE html>
    <html>
      <head>
        <title>js15.html</title>
        <script type="text/javascript">
            if(confirm("你想继续么?"))
            {
                window.location.href = "http://www.baidu.com";
            }
            else
            {
                alert("bye");
            }
        </script>
    
      </head>
      
      <body>
        This is my HTML page. <br>
      </body>
    </html>

    可以选择。

    模式对话框:不操作就不能继续

    非模式: 不操作,仍然可以继续后面窗口的操作。

    查看屏幕高度:

    <html>
      <head>
        <title>js15.html</title>
      </head>
      
      <body>
            <script type="text/javascript">
            with(document)
            {
                write("屏幕设定值<br>");
                write("实际高度:", screen.availHeight, "<br>");
                write("实际宽度:", screen.availWidth,"<br>");
                write("屏幕区域高度:", screen.height,"<br>");
                write("屏幕区域宽度:", screen.width,"<br>");
            }
        </script>
      </body>
    </html>

    屏幕设定值
    实际高度:740
    实际宽度:1024
    屏幕区域高度:768
    屏幕区域宽度:1024

     

  • 相关阅读:
    The nineteenth day
    The eighteen day
    弱读下
    弱读上
    失爆 爆破音
    连读
    The seventeenth day
    The sixteenth day
    React 官方脚手架 create-react-app快速生成新项目
    pc端引入微信公众号文章
  • 原文地址:https://www.cnblogs.com/backpacker/p/2613770.html
Copyright © 2011-2022 走看看