[Greasemonkey] clientWidth not updated after page "greased"
daddydave
daddydave at gmail.com
Mon May 8 12:46:52 EDT 2006
This is resolved! Thanks for all your help, Jeremy!
This is what it took
imgGoto.addEventListener('error', function(e) {
this.setAttribute ('src', 'http://ma.gnolia.com/favicon.ico');
}, true);
Previously I was trying to do imgGoto.setAttribute... in the event handler
Ma.gnolia Condenser
http://userscripts.org/scripts/show/3936
On 5/8/06, Jeremy Dunck <jdunck at gmail.com> wrote:
>
> 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);
> }
> _______________________________________________
> Greasemonkey mailing list
> Greasemonkey at mozdev.org
> http://mozdev.org/mailman/listinfo/greasemonkey
>
More information about the Greasemonkey
mailing list