Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
IE用のJavaScriptコンソール
// compressed by Closure Compiler (http://closure-compiler.appspot.com/)
javascript:(function(c,d,b,k,l,m){function g(){var a=d("textarea");a.rows=k;a.cols=l;return a}d=c[d];b=c.body[b];var h=g();b(h);var n={"\u000c":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","'":"\\'","'":"\\'"},o=/(\f|\n|\r|\t|\'|')/g;c=function(a){a.innerText=m;a.attachEvent("onclick",function(){var e;try{var f=h.value;f=f.replace(/\\/g,"\\\\").replace(o,function(p){return n[p]});e=(new Function("return eval('"+f+"')"))()}catch(i){e=i.name+": "+i.message}j.value=e});return a}(d("button"));b(c);var j=g();b(j)})(document, "createElement","appendChild",10,60,"exec");
// IE用の簡易JavaScriptコンソールを表示させます
// IE用のコードのため、IE以外のブラウザでは動作しません(attachEventなど)
// 圧縮時に文字数を節約するため、JSLintでは推奨されない記述が多々あります
(function(document, createElement, appendChild, x, y, label) {
createElement = document[createElement], appendChild = document.body[appendChild];
var createArea = function() {
var area = createElement("textarea");
area.rows = x;
area.cols = y;
return area;
}
var inputArea = createArea();
appendChild(inputArea);
var map = {
"\f": "\\f",
"\n": "\\n",
"\r": "\\r",
"\t": "\\t",
"\'": "\\\'",
"'": "\\'"
};
var escapes = /(\f|\n|\r|\t|\'|')/g
var button = (function(button) {
button.innerText = label;
button.attachEvent("onclick", function(button) {
var result ;
try {
var code = inputArea.value;
code = code.replace(/\\/g, "\\\\").replace(escapes, function(s) {
return map[s]
});
// globalのコンテキストで実行するため
result = (new Function("return eval('" + code + "')"))();
} catch(e) {
result = e.name + ': ' + e.message;
}
outputArea.value = result;
});
return button;
})(createElement("button"));
appendChild(button);
var outputArea = createArea();
appendChild(outputArea);
}(document, "createElement", "appendChild", 10, 60, "exec"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment