用 onerror 获取错误信息(2)_Dreamweaver教程
tmp.moveToPoint(r.getBoundingClientRect().left, sel.getClientRects()[0].top);
if(sel.parentElement() != tmp.parentElement()) return;
sel.setEndPoint('startToStart', tmp);
sel.text = '\t' sel.text.replace(/\r\n/g, '\r\t');
code = code.replace(/\r\n/g, '\r\t');
r.findText(code);
r.select();
}else{
sel.text = '\t';
sel.select();
}
break
case (13) :
tmp = sel.duplicate();
tmp.moveToPoint(r.getBoundingClientRect().left, sel.getClientRects()[0].top);
if(sel.parentElement() != tmp.parentElement()) return;
tmp.setEndPoint('endToEnd', sel);
sel.text = '\r\n' tmp.text.replace(tmp.text.replace(/^[\t ] /g, ""),"");
sel.select();
break;
default :
event.returnValue = true;
break;
}
return;
}
function runcode() {
var str = document.getElementById("txt_main").value;
var code_win = window.open('about:blank');
code_win.document.open();
code_win.document.writeln("<script>");
code_win.document.writeln("function reportError(msg,url,line){\nline-=14;\nvar str='You have found an error as below: \\n\\n';\nstr ='Err: ' msg ' on line: ' (line);\nalert(str);\nopener.goto(line);\nopener.focus();\nwindow.onerror=null;\nsetTimeout('self.close()',10);\nreturn true;\n}");
code_win.document.writeln("window.onerror = reportError;");
code_win.document.writeln("<\/script>");
code_win.document.writeln(str);
code_win.document.close();
return;
}
function savecode() {
var str = document.getElementById("txt_main").value;
var code_win = window.open('about:blank','_blank','top=10000');
code_win.document.open();
code_win.document.writeln(str);
code_win.document.close();
code_win.document.execCommand('saveas','','code.html');
code_win.close();
return;
}
function goto(ln) {
if(!/^\d $/.test(ln) || ln==0) return;
var obj = document.getElementById("txt_main");
var rng = obj.createTextRange();
var arr = obj.value.split(/\n/);
if(ln>arr.length) ln = arr.length;
var str_tmp = "";
for(var i=0; i<ln-1; i ) {
str_tmp = arr[i];
}
rng.moveStart('character',str_tmp.length);
str_tmp = "";
for(i=ln; i<arr.length; i ) {
str_tmp = arr[i];
}
rng.moveEnd('character',-str_tmp.length);
rng.select();
return;
}
window.onload = function() {document.getElementById("txt_main").value = "<script>\nalert(')\n<\/script>";}
</script>
<BODY>
<table width='600' class='list' border='1' bgcolor='#eeeeee' bordercolorlight='#000000' bordercolordark='#FFFFFF' cellpadding='0' cellspacing='0'>
<tr bgcolor='#cccccc'>
<td colspan='2' height='20' align='center'><b>Debug Textarea</b></td>
</tr>
<tr>
<td colspan='2'>
<table width='95%' border='0' align='center' >
- 相关链接:
- 教程说明:
Dreamweaver教程-用 onerror 获取错误信息(2)。