添加一个默认的window.onerror

This commit is contained in:
shijian 2023-12-27 23:07:16 +08:00
parent cb8d95c617
commit 8588174be6
1 changed files with 20 additions and 10 deletions

View File

@ -1,11 +1,21 @@
<!DOCTYPE HTML> <!DOCTYPE HTML>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="format-detection" content="telephone=no"> <meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="user-scalable=no, viewport-fit=cover"> <meta name="viewport" content="user-scalable=no, viewport-fit=cover">
<title>无名杀</title> <title>无名杀</title>
<script>
window.onerror = function (msg, src, line, column, err) {
var str = `错误文件: ${typeof src == 'string' && src.length > 0 ? decodeURI(src) : '未知文件'}`;
str += `\n错误信息: ${msg}`;
str += `\n行号: ${line}`;
str += `\n列号: ${column}`;
if (err && err.stack) str += '\n' + decodeURI(err.stack);
console.error(str);
alert(str);
};
</script>
<script src="game/update.js"></script> <script src="game/update.js"></script>
<script src="game/config.js"></script> <script src="game/config.js"></script>
<script src="game/package.js"></script> <script src="game/package.js"></script>