<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>debug on adolsai's echo</title><link>https://adolsai.com/tag/debug/</link><description>Recent content in debug on adolsai's echo</description><generator>Hugo</generator><language>zh-CN</language><lastBuildDate>Wed, 26 Feb 2014 22:31:25 +0800</lastBuildDate><atom:link href="https://adolsai.com/tag/debug/index.xml" rel="self" type="application/rss+xml"/><item><title>js debug function</title><link>https://adolsai.com/archives/8.html</link><pubDate>Wed, 26 Feb 2014 17:30:00 +0800</pubDate><guid>https://adolsai.com/archives/8.html</guid><description>&lt;pre&gt;&lt;code&gt;//在document中的一个指定的区域输出调试信息&#10;//如果document不存在这样的一个区域，则创建一个&#10;function debug(msg){&#10; //通过查看HTML元素id属性来查找文档的调试部分&#10; var log = document.getElementById("debuglog");&#10;&#10; if (!log){&#10; log = document.createElement("div");&#10; log.id = "debuglog";&#10; log.innerHTML = "&amp;lt;h1&amp;gt;Debug Log&amp;lt;/h1&amp;gt;";&#10; document.body.appendChild(log);&#10; }&#10; //将消息包装在&amp;lt;pre&amp;gt;中，并添加到log中&#10; var pre = document.createElement("pre");&#10; var text = document.createTextNode(msg);&#10; pre.appendChild(text);&#10; log.appendChild(pre);&#10;}&#10;&lt;/code&gt;&lt;/pre&gt;</description></item></channel></rss>