js阻止浏览器默认行为的简单实例
作者:jingxian 时间:2024-04-27 15:22:55
js阻止浏览器默认行为的简单实例
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<a id="a1" href="http://www.baidu.com">百度</a>
<script>
function stopDefault(e){
//非IE
if(e && e.preventDefault)
e.preventDefault();
//IE
else
window.event.returnValue = false;
}
window.onload = function(e){
var a1 = document.getElementById("a1");
a1.onclick = function(e){
stopDefault(e);
}
};
</script>
</body>
</html>
标签:js,阻止,浏览器,默认
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
如何用python编写一个生成春联软件
2021-12-12 07:27:47
![](https://img.aspxhome.com/file/2023/0/121610_0s.jpg)
golang中set数据结构的使用示例
2024-02-17 22:06:19
用实例分析如何整理SQL Server输入数据
2009-01-20 15:16:00
Python实现发送QQ邮件的封装
2022-10-08 21:19:56
![](https://img.aspxhome.com/file/2023/9/97269_0s.jpg)
ubuntu下设置mysql自动备份的例子
2024-01-21 18:09:08
跟老齐学Python之网站的结构
2021-08-22 05:55:54
![](https://img.aspxhome.com/file/2023/8/95468_0s.png)
Python操作Sql Server 2008数据库的方法详解
2024-01-20 04:47:01
![](https://img.aspxhome.com/file/2023/9/72239_0s.jpg)
MySQL跨服务器数据映射的实现
2024-01-23 15:08:19
![](https://img.aspxhome.com/file/2023/4/67524_0s.png)
Python实现将HTML转成PDF的方法分析
2023-06-19 18:59:37
![](https://img.aspxhome.com/file/2023/2/99552_0s.png)
perl的格式化(Format)报表输出实现代码
2022-02-10 09:43:47
js数字转换为float,取N位小数
2024-05-03 15:08:33
python选择排序算法实例总结
2023-08-29 06:58:28
详细总结Python常见的安全问题
2022-04-22 14:19:20
PYQT5 vscode联合操作qtdesigner的方法
2023-10-31 16:46:41
![](https://img.aspxhome.com/file/2023/9/121889_0s.jpg)
pandas实现按照多列排序-ascending
2021-06-11 03:24:22
![](https://img.aspxhome.com/file/2023/9/131219_0s.png)
Python CSV 文件解析和生成方法示例
2022-12-25 10:52:58
Python-copy()与deepcopy()区别详解
2021-06-20 15:00:41
mssql 指定字段编号sql语句
2024-01-21 18:58:53
![](https://img.aspxhome.com/file/2023/0/105470_0s.gif)
js表格拖选动态效果COOL而实用
2007-08-05 12:07:00
![](https://img.aspxhome.com/file/UploadPic/up/2007080512171065.gif)
Python实现多线程抓取妹子图
2022-10-02 15:39:25