以前的老代码,遍历JavaScript对象的参数名和对应值,用来调试显示JavaScript对象信息。
function debug(obj) {
if(obj) {
var s = '';
for(var itm in obj) {
s += 'obj.' + itm + '=' + obj[itm] + ';';
}
alert(s);
}
}
if(obj) {
var s = '';
for(var itm in obj) {
s += 'obj.' + itm + '=' + obj[itm] + ';';
}
alert(s);
}
}
例如,debug(window),得到的结果约为:
obj.top=[object];
obj.location=file:///D:/test.html;
obj.parent=[object];
obj.offscreenBuffering=auto;
obj.frameElement=null;
obj.onerror=null;
obj.screen=[object];
obj.event=null;
obj.clipboardData=[object];
obj.onresize=null;
obj.defaultStatus=;
obj.onblur=null;
obj.window=[object];
...
obj.location=file:///D:/test.html;
obj.parent=[object];
obj.offscreenBuffering=auto;
obj.frameElement=null;
obj.onerror=null;
obj.screen=[object];
obj.event=null;
obj.clipboardData=[object];
obj.onresize=null;
obj.defaultStatus=;
obj.onblur=null;
obj.window=[object];
...