默认事件~

Posted greenradish

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了默认事件~相关的知识,希望对你有一定的参考价值。

默认事件的阻止

  简单的默认事件阻止
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <a onclick="fn(event)" href="http://www.baidu.com">123</a>
        <script>
            //js和html是两门不同的语言,分开运行
            function fn(e)
                var e=e||window.event;
                if(e.preventDefault)
                    e.preventDefault();
                else
                    e.returnValue=false;//ie阻止默认事件
                
                console.log(e);
            
        </script>
    </body>
</html>

 

以上是关于默认事件~的主要内容,如果未能解决你的问题,请参考以下文章