[Greasemonkey] clientWidth not updated after page "greased"
daddydave
daddydave at gmail.com
Fri May 5 15:23:36 EDT 2006
I am changing the src of an img so that it points to an image URI which may
or may not exist. (which will be something like
http://some.hostname.org/favicon.ico)
The ones that don't exist I need to replace with a known good image URI.
I am trying to access the naturalWidth property in this function. But it
always returns true, naturalWidth and width are always 16, even with a bogus
URI. According the the DOM Inspector it is 0 on the bogus ones. So it
appears it is picking up the width *before* the page was greased. How do I
get the width of the image after the src attribute was greased to a new URI?
(Note: I know the image is replacing properly if it exists, but if it
doesn't it shows the img title attribute text instead of the image, yet
width is still 16)
Alternatively, if I need to do an existence test for the uri prior to
replacing it, that would work, too, but I don't know how to do that either.
function hasFavicon(img) {
GM_log("natural width: " + img.naturalWidth+ "; client width: " +
img.clientWidth + "; width: " + img.width);
if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
return false;
}
return true;
}
Thanks in advance for any help or information.
David Eason
Ma.gnolia Condenser
http://userscripts.org/scripts/show/3936
More information about the Greasemonkey
mailing list