HTMLページの中に貧しい人のFirebugを作成しようとしています。ターゲットページのどこかに配置された外部スクリプトを作成しました。 <body onload="monitor_init()">
で初期化されます。また、部分的に不透明なテーブルを結果とともに絶対的に配置するためのスタイルシートも用意されています。ウィンドウ内の変数(またはすべて)の表示名、html/javascript
window[]
のすべての値(値)を実行し、それを1つの列に表示し、typeof(window[i])
を別の列に表示します。また、変数またはオブジェクトの名前を表示する別の列を持っていると思います。
function monitor_init()
{
var css = document.createElement("link");
css.setAttribute("href","jsmonitor.css");
css.setAttribute("rel","stylesheet");
css.setAttribute("type","text/css");
document.getElementsByTagName("head")[0].appendChild(css);
var temp = document.createElement("div");
temp.setAttribute("id","monitor_box");
var temp2 = document.createElement("table");
temp2.setAttribute("id","monitor_output");
temp.appendChild(temp2);
document.body.appendChild(temp);
monitor();
}
var monitor_speed = 100;
function monitor()
{
while(document.getElementById("monitor_output").childNodes.length > 0)
{
document.getElementById("monitor_output").removeChild(document.getElementById("monitor_output").lastChild);
}
for (i in window)
{
if (["function","undefined"].indexOf(typeof(window[i]))!=-1)
{
continue;
}
// This is where I tried to make a first column displaying the name, couldn't find anything that worked.
// Disregard the .name, that was just last-ditch stuff
//var temp = document.createElement("tr");
//var temp2 = document.createElement("td");
//temp2.appendChild(document.createTextNode(window[i].name));
//temp.appendChild(temp2);
var temp = document.createElement("tr");
var temp2 = document.createElement("td");
temp2.appendChild(document.createTextNode(typeof(window[i])));
temp.appendChild(temp2);
var temp2 = document.createElement("td");
temp2.appendChild(document.createTextNode(window[i]));
temp.appendChild(temp2);
document.getElementById("monitor_output").appendChild(temp);
}
setTimeout("monitor()",monitor_speed);
}
typeofを使用することで、関数の値と未定義の値の表示をスキップすることができました。名前にアクセスできるようになるためには、JavaScriptの数字、文字列、配列オブジェクトなどではない履歴、場所、その他のもの、つまり他のスクリプトで作成したグローバル変数ページ上に - なぜあなたは放火魔のライトを使用することはできません
for (i in window) {
// at the point, i is a string containing the name of the property
// window[i] contains the value of that property
document.write('window.' + i + ' is ' + window[i] + '<br>');
}
が、別のポスターなど
は尋ねた:
Firegut Liteを使うことはできません。 http://getfirebug.com/firebuglite –