I'm trying to design a label that will go on a toolbar that I've made for Mozilla Firefox. I need the label to update based on whether or not there is a cookie stored for the URL I am focused on. If there isn't a cookie for the page the label would be blank and if there is a cookie for the page it would display the value of the cookie.

At the moment I'm using a window.onchange event to call alert(document.location.href).

My first problem was that I noticed changing tabs in Firefox does not trigger this event but my more major problem is that when the event is triggered the alert displays:


when I expected the URL of the page I'm visiting.

The function I'm calling is located inside of a Javascript file inside of:

I definitely think that this has something to do with the encapsulation of my toolbar but I'm not sure.

Thanks for your help.