作者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