hook了window.onerror事件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<script>
window.onerror = function (msg, url, lineNo, columnNo, error) {
var string = msg.toLowerCase();
var substring = "script error";
if (string.indexOf(substring) > -1){
//alert('Script Error: See Browser Console for Detail');
var message = [
'Message: ' + msg,
'URL: ' + url,
'Line: ' + lineNo,
'Column: ' + columnNo,
'Error object: ' + JSON.stringify(error)
].join('\n');
alert('window.onerror: script error '+ message);
} else {
var message = [
'Message: ' + msg,
'URL: ' + url,
'Line: ' + lineNo,
'Column: ' + columnNo,
'Error object: ' + JSON.stringify(error)
].join('\n');
if(msg.indexOf('SyntaxError') != -1 || msg.indexOf('Uncaught ReferenceError') != -1){
console.log(message);
alert('window.onerror: SyntaxError'+ message);
}
}
return false;
};
</script>
<script>
a=s2
</script>