単一ページのダウンロード ウェブサイトのタイトル #div1 .bObject { cursor:pointer; color:Blue; } #div1 .bError { color:Red; } #div1 div { margin-left:20px; border:solid 1px gray; padding:5px; } #div1 th { text-align:left; background-color:#fef; } #div1 td { vertical-align:top; } null 値をマスクする [Ctrl A すべて選択 注: 外部 Js を導入する必要がある場合は、更新して実行する必要があります ] function getObject() { var chkNull = document.getElementById('chkNull'); eval('var obj=' + document.getElementById('txt').value + ';'); var str = '<table border="1" cellpadding="3" style="border-collapse:collapse;">'; str += '<tr><th>类型<th>名称<th>值'; for (var i in obj) { var strItem = '<tr>'; try { if(chkNull.checked && (obj[i] == null || obj[i] == undefined)){ continue; } strItem += '<td>' + typeof (obj[i]) + ''; if (obj[i] != null && typeof (obj[i]) == 'object') { strItem += '<td><b class="bObject">' + i + ''; } else { strItem += '<td><b>' + i + ''; } if (obj[i] != null && (typeof (obj[i]) == 'string' || typeof (obj[i]) == 'function')) { strItem += '<td>' + formatHTML(obj[i]) + ''; } else { strItem += '<td>' + obj[i] + ''; } strItem += ''; } catch (e) { strItem = '<tr><td class="bError" colspan="3">' + i + ' error:' + e + ''; } str += strItem; } str += ''; var div1 = document.getElementById('div1'); div1.innerHTML = str; var bs = div1.getElementsByTagName('b'); for (var i = 0; i < bs.length; i++) { if (bs[i].className == 'bObject') { bs[i].onclick = show; } } } function formatHTML(obj) { var strHTML = obj.toString(); if (strHTML.length > 10000) { return '字符长度:' + strHTML.length + '字节'; } strHTML = strHTML.replace(/&/g, '&'); strHTML = strHTML.replace(/, '<'); strHTML = strHTML.replace(/>/g, '>'); strHTML = strHTML.replace(/\n/g, '<br>'); strHTML = strHTML.replace(/\t/g, '    '); strHTML = strHTML.replace(/ /g, ' '); return strHTML; } function goUp() { var txt = document.getElementById('txt'); if (txt.value.lastIndexOf(']') == txt.value.length - 1) { txt.value = txt.value.substr(0, txt.value.lastIndexOf('[')); getObject(); return; } if (txt.value.indexOf('.') != -1) { txt.value = txt.value.substr(0, txt.value.lastIndexOf('.')); getObject(); return; } } function show() { var txt = document.getElementById('txt'); var r = /^\+?[0-9][0-9]*$/; //正整数 if (r.test(this.innerHTML)) { txt.value += '[' + this.innerHTML + ']'; } else { txt.value += '.' + this.innerHTML; } getObject(); } パッケージ化してダウンロード getObject();