📄 debug.js
字号:
/*弹出一个窗口显示JavaScript错误.*/
var error_count = 0;
function report_error(msg, url, line){
var winw = 500;
var winh = 350;
var w = window.open("", // URL (none specified)
"error"+error_count++, // Name (force it to be unique)
"resizable,status,width=" + winw + ",height=" + winh); // Features
w.moveTo((screen.availWidth-winw)/2,(screen.availHeight-winh)/2);
var d = w.document;
d.write('<div align="center">');
d.write('<font size="7" face="helvetica"><b>');
d.write('OOPS.... A JavaScript Error Has Occurred!');
d.write('</b></font><br><hr size="4" width="80%">');
d.write('<font size="3">');
d.write('<input type="button" value="Close" onclick="window.close();">');
d.write('</div><div align="left">');
d.write('<br>Message: ');
d.write('<input size="60" name="message" value="' + msg + '">');
d.write('<br>Document: <input size="60" name="url" value="' + url + '">');
d.write('<br>Line: <input size="60" name="line" value="'+line +'">');
d.write('</div></font>');
d.close();
return true;
}
//window.onerror = report_error;
//window.onerror = function() { return true; }
function showClientInfo(){
alert("窗口宽度:" + window.document.body.clientWidth + ",窗口高度:" + window.document.body.clientHeight);
}
function debugMsg(msg){
var winw = 900;
var winh = 500;
var w = window.open("", // URL (none specified)
"DebugMsgWindow", // Name (force it to be unique)
"resizable,status,scrollbars=yes,width=" + winw + ",height=" + winh); // Features
// w.moveTo((screen.availWidth-winw)/2,(screen.availHeight-winh)/2);
var doc = w.document;
if(w.i == null){
w.i = 1;
}
var n = w.i;
var str = (msg + "").replace(/\</g, "<");
str = str.replace(/\>/g, ">");
str = str.replace(/\r\n/g, "<br/>");
str = '<div style="width:70%;">' + '<span style="color:red;font-weight:700;">' + n + ": " + '</span>' + str + '</div>';
doc.write("<br/>");
doc.write(str);
w.i = n + 1;
return true;
}
function debugInfo(msg){
if(debugInfo.i == null){
debugInfo.i = 1;
debugInfo.pred = null;
}
var str = (msg + "").replace(/\</g, "<");
str = str.replace(/\>/g, ">");
str = str.replace(/\r\n/g, "<br/>");
var d = document.createElement("DIV");
d.style.width = "70%";
d.innerHTML = "<br/>" + debugInfo.i + ": " + str;
document.body.insertBefore(d, debugInfo.pred);
debugInfo.pred = d;
debugInfo.i ++;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -