zoukankan      html  css  js  c++  java
  • 捕获浏览器的前进、后退事件 window.onhashchange 并区别于点击链接

    <html>   
        
        <head>   
            <meta http-equiv="content-type" content="text/html;charset=utf-8">   
            <title>onhashchange测试</title></head>   
        
        <body>
                <a href="#p2">p2</a>
        <script>
           document.onmouseover = function() {
                //User's mouse is inside the page.
                window.innerDocClick = true;
            }
    
            document.onmouseleave = function() {
                //User's mouse has left the page.
                window.innerDocClick = false;
            }
    
            window.onhashchange = function() {
                if (window.innerDocClick) {
                    //Your own in-page mechanism triggered the hash change
                    alert('You click a link');
                } else {
                    //Browser back button was clicked
                    alert('You click browser button');
                }
            }   </script>   
    </html>
    

      

  • 相关阅读:
    二分法排序
    GDB调试命令
    X264编译
    ffmpeg编译
    css-icons
    Javascript组成--ECMAScript,DOM,BOM
    9 Utils
    8 移动端填坑
    7 媒体查询( Media Queries )
    css3--rem
  • 原文地址:https://www.cnblogs.com/bushe/p/5950429.html
Copyright © 2011-2022 走看看