码迷,mamicode.com
首页 > 编程语言 > 详细

JavaScript

时间:2017-06-13 18:27:46      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:int   ima   min   led   img   win   src   lan   develop   

 

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>

实现效果为:

技术分享

 

 

 

 技术分享

 

JavaScript

标签:int   ima   min   led   img   win   src   lan   develop   

原文地址:http://www.cnblogs.com/alexanderthegreat/p/7001904.html

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