Am 12.10.2012 15:30, schrieb GmUser:
I know we used to discuss this issue quite a bit back when
Greasemonkey was in its infancy.

It sure would be nice if it could be implemented, though.

I know (assume it's still true) that images don't have the
early load event, and maybe they (still?) don't have an
onload or similar event, but if they do, or if something
can be done, it would be really nice to have this ability
so those of us who want to write scripts for images
can do so. (like, as merely one example, a semi-intelligent
image zoomer to have images displayed in a certain
size, or any number of other possibilities)


You can append a "load" event listener to elements, too. On images, this event is fired as soon as the image ressource was loaded.

Testfile "gmtest.html"
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<!-- Some large pic that'll take a second to load -->
<img id="pic" src="http://www.geeknaut.com/images/windows-wallpapers/Winodws-7-aurora-wallpaper.jpg"; width="1920" height="1200" />
</body>
</html>

Note that the following test script will only work if you set the "greasemonkey.fileIsGreaseable" option in about:config to "true" during the test. Don't forget to disable it later.
// ==UserScript==
// @name        Test
// @namespace   LWChris
// @include     file://*gmtest.html
// @version     1
// @grant       none
// ==/UserScript==

picLoad = function(evt) {
  document.title += " pic";
}

document.getElementById("pic").addEventListener("load", picLoad, false);
document.title += " append";

You will see the title is "Test" from the HTML file, it's "Test append" while the pic is loading, and "Test append pic" as soon as the image is ready.

Chris

--
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/greasemonkey-users?hl=en.

Reply via email to