0
以下是我在Chrome擴展中使用的代碼,它從本地存儲獲取URL並將其與網頁的當前網址進行比較..如何將變量與Chrome擴展中的本地存儲進行比較?
問題是,即使它們是一個,相同。(下面以一個HTTP =://www.google.com和b = HTTP://www.google.com)
var a="";
chrome.extension.sendRequest({method: "getLocalStorage", key: "url"}, function(response) {
a=response.data;
});
var b = document.location;
//I am trying to compare a and b but I always get they are equal even though they are one and the same
if (a==b)
{
alert("Equal");
}
,我會嘗試,但即使我的代碼它顯示正確only..When我使用一個單獨的警告框顯示,它的正確顯示,而這不是正確的比較.. – Shan 2012-02-09 08:58:03
嘗試使用'console.log()'代替'alert()'。您可以在代碼中的每一行後添加'console.log()',並查看真實的代碼工作流程。或者使用腳本debuger一步一步。 – anfilat 2012-02-10 05:41:12