1
喲社區!可能需要一些見解.. :)我正在學習一些更先進的js概念。即時通訊運行此代碼,但結果並沒有顯示,因爲我期待......我看不到錯誤...任何想法?謝謝!我試圖找到這個代碼中的錯誤,測試我的JavaScript代碼
<script type="text/javascript">
(function() {
var results, queue = [];
this.assert = function(pass, msg) {
var type = pass ? "PASS" : "FAIL";
var str = "<li class='" + type + "'><b>" +
type + "</b> " + msg + "</li>";
if (queue)
queue.push(str);
else
results.innerHTML += str;
};
window.addEventListener("load", function() {
results = document.getElementById("results");
results.innerHTML = queue.join('');
queue = null;
});
// calling assert but it's not showing up the <li> with the message....(why?)
assert(true, "I always pass!");
})();
</script>
請仔細閱讀[問] – nfechner
什麼是應該發生的?怎麼了? –
這裏適合我:http://jsfiddle.net/JDFuR/ - 你在測試什麼瀏覽器? – nnnnnn