Below is the code I use in Chrome extension which gets a url from local storage and compares it with current url of the webpage..
The problem is javascript is not showing them as equal even though they are one and the same..(Below a=http://www.google.com and 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");
}
You need to wait the response callback function. Change you code to: