[Greasemonkey] clientWidth not updated after page "greased"
Jeremy Dunck
jdunck at gmail.com
Mon May 8 11:10:26 EDT 2006
On 5/8/06, daddydave <daddydave at gmail.com> wrote:
> I think the problem was that I was trying to refer to variables that are out
> of scope in the event handler. I found an example that gives me the idea of
> referring to the img element using the this pointer. The example is old
> because it uses the older style Greasemonkey event handling, but I
> understand that part I think. :)
You can also create a closure over the variables you need to reference.
This is done by creating your event listener function within the
lexical scope that contains your referenced variables:
function doStuff() {
var allTheVariablesYouCareAbout = stuff;
function handler(e) {
var stuff;
var with;
var do = stuff + with + allTheVariablesYouCareAbout;
}
yourFaviconImg.addEventListener('error', handler, true);
}
More information about the Greasemonkey
mailing list