onerror事件捕获网页中的错误
2024-09-06 20:07:30
转载请注明来源:https://www.cnblogs.com/hookjc/
<html>
<head>
<script type="text/javascript">
onerror=handleErr
var txt=""
function handleErr(msg,url,l)
{
txt="There was an error on this page.\n\n"
txt+="Error: " + msg + "\n"
txt+="URL: " + url + "\n"
txt+="Line: " + l + "\n\n"
txt+="Click OK to continue.\n\n"
alert(txt)
return true
}
function message()
{
adddlert("Welcome guest!")
}
</script>
</head>
<body>
<input type="button" value="View message" onclick="message()" />
</body>
</html>
注:当点击按钮时出现错误,则触发onerror事件 即onerror=handleErr 去执行handleErr方法,msg为错误信息,url为当前显示的url地址,l表示错误的行号
来源:python脚本自动迁移
最新文章
- sql字段属性
- jq异步上传文件(转载)
- Result Maps collection does not contain value for java.lang.Integer异常处理
- C++学习13 类class和结构体struct的区别
- windows通过thrift访问hdfs
- Ubuntu 12.04 和 Win7 双系统安装
- Linux下glui 的安装,以及错误解决
- 大话设计模式之策略模式(strategy)
- 说说SACC2016第八届架构师大会
- jQuery实践-别踩白块儿网页版
- ios播放音乐
- 从CentOS安装完成到生成词云python学习日记
- python 视频转成代码视频
- JSONP方法简单封装
- type-of-python作业-判断字符串是否属于回文需要忽略其中的标点、空格与大小写
- 分布式 基本理论 CAP
- 学习2__STM32--汉字显示
- Codeforces 138C Mushroom Gnomes - 2 线段树
- 请教神牛_字符串hash
- bit,Byte,Word,DWORD(DOUBLE WORD,DW)