值undefined(表达式console.time的结果)不是对象

时间:2013-04-27 16:33:25

标签: javascript webkit symbian nokia

我在某些手机浏览器中创建了下一个代码并发现错误:

Mozilla/5.0 (SymbianOS/9.4; Series60/5.0 NokiaN97-1/22.0.110; Profile/MIDP-2.1 Configuration/CLDC-1.1) AppleWebKit/525 (KHTML, like Gecko) BrowserNG/7.1.4
Mozilla/5.0 (SymbianOS/9.4; Series60/5.0 Nokia5800d-1/52.0.007; Profile/MIDP-2.1 Configuration/CLDC-1.1 ) AppleWebKit/525 (KHTML, like Gecko) Version/3.0 BrowserNG/7.2.6.9 3gpp-gba
Mozilla/5.0 (SymbianOS/9.4; Series60/5.0 Nokia5228/40.1.003; Profile/MIDP-2.1 Configuration/CLDC-1.1 ) AppleWebKit/525 (KHTML, like Gecko) Version/3.0 BrowserNG/7.2.7.4 3gpp-gba
Mozilla/5.0 (SymbianOS/9.3; Series60/3.2 NokiaC5-00/031.022; Profile/MIDP-2.1 Configuration/CLDC-1.1 ) AppleWebKit/525 (KHTML, like Gecko) Version/3.0 BrowserNG/7.2.3.1
Mozilla/5.0 (SymbianOS/9.4; Series60/5.0 Nokia5230/40.0.003; Profile/MIDP-2.1 Configuration/CLDC-1.1 ) AppleWebKit/525 (KHTML, like Gecko) Version/3.0 BrowserNG/7.2.7.4 3gpp-gba

代码:

try {

var blank_function = function () {}; if (window) window.ll = 9423;
if (!window.console) {
    window.console = {time: blank_function, timeEnd: blank_function, log: blank_function, dir: blank_function}; if (window) window.ll = 9425;
}
if (!console.time) {
    console.time = blank_function; if (window) window.ll = 9428;
}
if (!console.timeEnd) {
    console.timeEnd = blank_function; if (window) window.ll = 9431;
}
if (!console.log) {
    console.log = blank_function; if (window) window.ll = 9434;
}
if (!console.dir) {
    console.dir = blank_function; if (window) window.ll = 9437;
}


console.time("other"); if (window) window.ll = 9441;

} catch(e) {if (window.send_exception && typeof window.send_exception == typeof function(){}) {window.send_exception(e);}}

它有什么问题?我不使用return value =>它可能是未定义的。 在其他浏览器中工作没有错误。

异常数据:

Array (
    [name] => TypeError
    [message] => Value undefined (result of expression console.time) is not object.
    [line] => 9442
    [toString] => TypeError: Value undefined (result of expression console.time) is not object.
)

PS抱歉英语不好。

PPS window.ll =行号 - 1。

1 个答案:

答案 0 :(得分:0)

我仍然只看到一个解释:

此JavaScript实现包含window.console对象,但没有方法time

但是,对象无法添加方法,因此blank_function的赋值不会给出任何内容。

在此之后无法完成调用,因为方法time不存在。