由於在 Chrome, IE, Firefox, Opera 還有 Safari 都有一些 console 語法不盡相同,為了避免一執行到就掛點,建議可以在你的 js 中加上以下語法,這樣就不會遇到在程式中忘了移除 console.log,結果在 IE8 就直接死掉的問題了!!
(function() { // Union of Chrome, Firefox, IE, Opera, and Safari console methods var methods = ["assert", "cd", "clear", "count", "countReset", "debug", "dir", "dirxml", "error", "exception", "group", "groupCollapsed", "groupEnd", "info", "log", "markTimeline", "profile", "profileEnd", "select", "table", "time", "timeEnd", "timeStamp", "timeline", "timelineEnd", "trace", "warn"]; var length = methods.length; var console = (window.console = window.console || {}); var method; var noop = function() {}; while (length--) { method = methods[length]; // define undefined methods as noops to prevent errors if (!console[method]) console[method] = noop; } })();
Next 使用 Chrome 來檢視動態 DOM
Facebook 討論區載入中...
資料夾 :
標籤 :
發表時間 :
2016-12-27 23:30:24
觀看數 :
5,335
發表人 :
Kuann Hung
部門 :
老洪的 IT 學習系統
QR Code :