Can I call canvas.drawWindow () from the onload handler?

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;
  // create an html:canvas, adjust its size, etc. following the example of the "TabPreview" extension
  var ctx = canvas.getContext("2d");
  ctx.drawWindow(win, 0, 0, w, h, "rgb(255, 255, 255");
  // add the canvas to the DOM
},
+3
source share
2

, , "", "".

onload , html . CSS , , 1.

MozAfterPaint. , Gecko .

, MozAfterPaint, DOM. , , , reset 100-200 ms tineout. . , , , , .

[1] , , undefined onload. script, JS , , onload.

+2

, Mozilla , canvas.drawWindow() load.

0

Source: https://habr.com/ru/post/1753606/


All Articles