zoukankan      html  css  js  c++  java
  • JavaScript

    1、onclick="javascript:window.close();"在Chrome中不起作用

    https://developer.mozilla.org/en-US/docs/Web/API/Window/close

    The Window.close() method closes the current window, or the window on which it was called.

    This method is only allowed to be called for windows that were opened by a script using the window.open() method. If the window was not opened by a script, an error similar to this one appears in the console: Scripts may not close windows that were not opened by script.

    所以window.close()不能打开不是使用window.open()打开的页面。如果想要把非window.open()打开的页面关闭,可以把window.close()改为:

    window.open("about:blank","_self").close();  

    2、使用javascript实现光棒效果

    <script type="text/javascript">
            function mine(dom){
                dom.style.background="red";
            }
            function myout(dom){
                dom.style.background="";
            }
        </script>
      </head>
      
      <body>
        <ul>
            <li onmouseover="javascript:mine(this)" onmouseout="javascript:myout(this)"></li>
            <li onmouseover="javascript:mine(this)" onmouseout="javascript:myout(this)"></li>
            <li onmouseover="javascript:mine(this)" onmouseout="javascript:myout(this)"></li>
        </ul>
      </body>

    实现的效果为:

    3、使用javascript得到按键的ASCⅡ值。

    <script type="text/javascript">
            function mykeyup(dom){
                alert(dom.keyCode);
            }
        </script>
      </head>
      
      <body>
        <input type="text" onkeyup="javascript:mykeyup(event)"/>
      </body>

    实现效果为:

     

     

  • 相关阅读:
    MySQL索引长度限制问题
    Mysql查询缓存碎片、缓存命中率及Nagios监控
    PHP多台服务器跨域SESSION共享
    php会话全揭秘
    深入PHP中慎用双等于(==)的详解
    php二进制安全的含义
    分表,分库算法
    php学习网站推荐
    在linux平台下,设置core dump文件属性(位置,大小,文件名等)
    常用Linux shell命令汇总
  • 原文地址:https://www.cnblogs.com/alexanderthegreat/p/7001904.html
Copyright © 2011-2022 走看看