-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsyntax-test.html
More file actions
42 lines (34 loc) · 1.09 KB
/
syntax-test.html
File metadata and controls
42 lines (34 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html>
<head>
<title>语法测试</title>
</head>
<body>
<h1>语法测试</h1>
<div id="output"></div>
<script>
const output = document.getElementById('output');
function log(message) {
const p = document.createElement('p');
p.textContent = message;
output.appendChild(p);
console.log(message);
}
log('开始语法测试...');
// 尝试加载classes.js
const script = document.createElement('script');
script.src = './js/classes.js';
script.onload = function() {
log('✅ classes.js 语法正确,加载成功');
};
script.onerror = function() {
log('❌ classes.js 加载失败,可能有语法错误');
};
document.head.appendChild(script);
// 监听语法错误
window.addEventListener('error', function(e) {
log(`❌ 语法错误: ${e.message} 在 ${e.filename}:${e.lineno}`);
});
</script>
</body>
</html>