それほど複雑な実装ではありませんが、毎回これを行うのは面倒なので、この出力ウィンドウを自動生成する小さなスクリプトを作成しました。
コード
window.Babu = { };
Babu.Debugging = {};
Babu.Debugging.writeLine = function(format, arg1, arg2) {
var console = Babu.Debugging._getConsole(); .get_visible( )) {
var msg = format;
if (typeof msg !== "未定義" && msg !== null) {
var インデックス;
if (typeof msg == = "string ") {
var array = format.match(/{(d )}/g);
if (array) {
for (var i = 0; i index = array[i];
index = parseInt(index.substr(1,index.length - 2)) 1;
msg = msg.replace(array[i],引数[インデックス]);
}
}
}
}
var span = document.createElement("SPAN");
span.appendChild(document.createTextNode(msg) );
console._output.appendChild(document.createElement("BR"));
span.scrollIntoView(); >}
}
Babu.Debugging._getConsole = function() {
var console = Babu.Debugging._console;
if (!console) {
var div = document.createElement( "DIV" );
div.style.right = "3px";
div.style.bottom = "3px"; .width = "350px";
div.style.height = "180px";
div.style.color = "黒"; .style.border = "solid 2px #afafaf";
div.style.fontSize = "12px";
Babu.Debugging._console = div;
div = document.createElement("DIV");
div.style.backgroundColor = "#e0e0e0";
div.style.position = "absolute"; "0px" ;
div.style.right = "0px";
div.style.height = "16px";パディング = " 2px 2px";
console.appendChild(div);
console._toolbar = div = document.createElement(" ");
div.style.overflow = "auto";
div.style.whiteSpace = "nowrap";
div.style.position = "absolute";
div.style.left = "0px";
div.style.top = "20px"; .height = "auto";
console._output = div;
btn = document.createElement("SPAN"); .innerHTML = "縮小";
btn.style.margin = "0px 3px";
console._toolbar.appendChild(btn); .onclick = function() { if (console.get_collapsed()) console.expand(); else console.collapse(); }
btn = document.createElement("SPAN"); "クリア" ;
btn.style.margin = "0px 3px";
console._toolbar.appendChild(btn); Babu.Debugging .clearConsole;
btn = document.createElement("SPAN");
btn.style.cursor = "pointer"; .margin = "0px 3px";
console._toolbar.appendChild(btn);
btn.onclick = function() { Babu.Debugging.hideConsole() }
console.get_visible = function(); { return this .style.display !== "none" };
console.get_collapsed = function() { return !(!this._collapseState) };
console.collapse = function() {
if (! this.get_collapsed()) {
this._output.style.display = "none";
this._toolbar.childNodes[1].style.display = "none"; _toolbar.childNodes [2].style.display = "none";
this._toolbar.childNodes[0].innerHTML = "expand";
this._collapseState = { width: this.style.width, height : this.style.height }
this.style.width = "30px";
}
}
console.expand = function( ) {
if (this.get_collapsed()) {
this._output.style.display = "";
this._toolbar.childNodes[1].style.display = ""; this._toolbar .childNodes[2].style.display = "";
this._toolbar.childNodes[0].innerHTML = "折りたたむ";
this.style.width = this._collapseState.width; 🎜>this .style.height = this._collapseState.height;
this._collapseState = null;
}
}
コンソールに戻ります。 Debugging.showConsole = function() {
Babu.Debugging._getConsole().style.display = "";
}
Babu.Debugging.hideConsole = function() {
var console = Babu .Debugging._console;
if (コンソール) {
console.style.display = "none";
Babu.Debugging.clearConsole = function() {
var console = Babu.Debugging._console;
if (console) console._output.innerHTML = "";
}
呼び出しメソッドは非常に簡単です:
コードをコピー
コードは次のとおりです:
Babu.Debugging.writeLine("デバッグ情報");
Babu.Debugging.writeLine("パラメータ付きのデバッグ情報: パラメータ 1={0}、パラメータ 2={1}"、arg1 、 arg2);
呼び出し後、固定位置のウィンドウがウィンドウの右下隅に自動的に表示され、対応するコンテンツが表示されます。以下のレンダリングをご覧ください:


去掉重复并排序的方法:1、使用“Array.from(new Set(arr))”或者“[…new Set(arr)]”语句,去掉数组中的重复元素,返回去重后的新数组;2、利用sort()对去重数组进行排序,语法“去重数组.sort()”。

本篇文章给大家带来了关于JavaScript的相关知识,其中主要介绍了关于Symbol类型、隐藏属性及全局注册表的相关问题,包括了Symbol类型的描述、Symbol不会隐式转字符串等问题,下面一起来看一下,希望对大家有帮助。

怎么制作文字轮播与图片轮播?大家第一想到的是不是利用js,其实利用纯CSS也能实现文字轮播与图片轮播,下面来看看实现方法,希望对大家有所帮助!

本篇文章给大家带来了关于JavaScript的相关知识,其中主要介绍了关于对象的构造函数和new操作符,构造函数是所有对象的成员方法中,最早被调用的那个,下面一起来看一下吧,希望对大家有帮助。

方法:1、利用“点击元素对象.unbind("click");”方法,该方法可以移除被选元素的事件处理程序;2、利用“点击元素对象.off("click");”方法,该方法可以移除通过on()方法添加的事件处理程序。

本篇文章给大家带来了关于JavaScript的相关知识,其中主要介绍了关于面向对象的相关问题,包括了属性描述符、数据描述符、存取描述符等等内容,下面一起来看一下,希望对大家有帮助。

foreach不是es6的方法。foreach是es3中一个遍历数组的方法,可以调用数组的每个元素,并将元素传给回调函数进行处理,语法“array.forEach(function(当前元素,索引,数组){...})”;该方法不处理空数组。

本篇文章给大家带来了关于JavaScript的相关知识,其中主要介绍了关于BOM操作的相关问题,包括了window对象的常见事件、JavaScript执行机制等等相关内容,下面一起来看一下,希望对大家有帮助。


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

ドリームウィーバー CS6
ビジュアル Web 開発ツール

メモ帳++7.3.1
使いやすく無料のコードエディター

Safe Exam Browser
Safe Exam Browser は、オンライン試験を安全に受験するための安全なブラウザ環境です。このソフトウェアは、あらゆるコンピュータを安全なワークステーションに変えます。あらゆるユーティリティへのアクセスを制御し、学生が無許可のリソースを使用するのを防ぎます。

SublimeText3 英語版
推奨: Win バージョン、コードプロンプトをサポート!

ZendStudio 13.5.1 Mac
強力な PHP 統合開発環境

ホットトピック



