The bottom of this Mozilla wiki page currently says: “Using canvas.drawWindow () doesn’t work when processing the onload event of a document. In Firefox 3.5 or later, you can do this in the MozAfterPaint event handlerto successfully draw HTML content into the canvas when the page loads. "This is good, except that I tried it in Firefox 3.6.6, and it really worked, which led me to think that it might not work, because of some error that has since been fixed, I would prefer not to use MozAfterPaint, since it will not work in versions prior to 3.5. Is there an important reason not to use the "load" event, and if so, what can I to do instead, which will be compatible with older versions of Firefox?
EDIT: This is how my code works. The function init()of my extension I call the gBrowser.addEventListener("load", MyExtension.onPageLoad, true);time MyExtension.onPageLoadto the point:
onPageLoad : function(e) {
var win = e.originalTarget.defaultView;
var ctx = canvas.getContext("2d");
ctx.drawWindow(win, 0, 0, w, h, "rgb(255, 255, 255");
},
source
share