[Greasemonkey] clientWidth not updated after page "greased"
Jeremy Dunck
jdunck at gmail.com
Fri May 5 15:12:09 EDT 2006
On 5/5/06, daddydave <daddydave at gmail.com> wrote:
> So it
> appears it is picking up the width *before* the page was greased.
No, greasemonkey scripts see the same DOM as DOM Inspector.
Setting the img src attribute is asynchronous and your code is winning
the race, so your script is picking up the property value before the
new image has been fetched and/or rendered, and thus the props you're
checking haven't been updated.
You should wait for the load to succeed or fail, then proceed. This
also nicely branches your "has/doesn't have" code. ;-)
yourImage.addEventListener('load', function(e) {
//do stuff which depends on successful load
}, true);
yourImage.addEventListener('error', function(e) {
//do stuff which depends on unsuccessful load.
}, true);
More information about the Greasemonkey
mailing list