這是我最簡單的代碼:Javascript,變量未被賦值...爲什麼?
var this_version =null;
this.timervar = setTimeout(function() {
try {
// Firefox 4 and later; Mozilla 2 and later
Components.utils.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAddonByID("[email protected]", function(addon) {
this_version = addon.version;
alert("r "+this_version);
});
} catch (ex) {
// Firefox 3.6 and before; Mozilla 1.9.2 and before
var em = Components.classes["@mozilla.org/extensions/manager;1"]
.getService(Components.interfaces.nsIExtensionManager);
var addon = em.getItemForID("[email protected]");
this_version = addon.version;
alert("rr " + this_version);
}
alert("rrr " + this_version);
}, 2000);
及其該死奇怪,因爲這個閃光兩次alert("r "+this_version);
但這alert("rrr "+this_version);
總是給我空;(
仍在學習JS,所以這是非常令人費解.. 。請大家幫忙!
謝謝!
當格式化爲 – qwertymk
ok,固定格式 – Ryan
那麼沒有人會打擾你看看你的代碼。並且在單個r的警報之前是否發生了三重r的警報? –