作者nightspirit (鞭策自己社清流夜靈)
看板Ajax
標題Re: [問題] alert( $.ajax )
時間Wed Feb 8 05:56:05 2012
※ 引述《Qiqi (潑潑)》之銘言:
: → terlin10:只是要給自己看的,就用console.log吧! 02/03 21:20
: 推 mrbigmouth:console.log會在ie8以下出bug...要放上網路前記得砍掉 02/05 06:28
Console.log實在是讓人又愛又恨,IE因為沒有內建Console所以會出錯,
為了解決問題,通常我會在網頁主要的master框架下放上一段JS
var alertFallback = false;
if (typeof console === "undefined" || typeof console.log === "undefined") {
console = {};
if (alertFallback) {
console.log = function (msg) {
alert(msg);
};
console.dir = function (msg) {
alert(msg);
};
} else {
console.log = function () { };
console.dir = function () { };
}
}
這樣一來就可以解決Browser沒有自帶console函式的問題了
其中alertFallback 改成 true的話 console.log 或 .dir就會改叫 alert
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 66.122.205.38
1F:推 showsky:不建議使用 alert 會使所有 thread 停住... 請用 <div> 02/08 22:35
2F:→ showsky:append content 02/08 22:35
3F:→ nightspirit:反正自定義的log dir就可以自己去改寫了~ 看需求 02/09 08:22
4F:→ nightspirit:通常我是直接關掉~ 反正我debug都用chrome 02/09 08:22