取消事件的默认动作
直接写return false;IE、FF、Chrome都可以
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script type="text/javascript"> 
        //页面加载的时候
        onload = function () {
            //给单机a标签增加一个点击事件
            document.getElementById('a1').onclick = function (evt) {
                //当单机的时候有alt的时候
                if (arguments[0].altKey) {
                    //弹出当前事件
                    alert(new Date().toLocaleTimeString());
                    
                    //IE中取消默认事件的方法,好像现在也不行了
                    //window.event.returnValue = false;
                    //火狐中取消默认事件的方法。
                    arguments[0].preventDefault();
                    //支持火狐和IE。据说 推荐使用的方法
                    //return false;
                };
            };
        };
    </script>
</head>
<body>
    <a href="http://www.baidu.com" id="a1" target="_blank">跳到百度去,加alt可以显示时间</a>
</body>
</html>
                    
                
                
            
        
浙公网安备 33010602011771号