[Project_owners] javascript print question

Brian King brian at mozdev.org
Mon Aug 21 10:46:10 EDT 2006


Is it possible to intercept in the browser (from chrome) a print command 
from Javascript, i.e.

- window.print()
- javascript:print()

I have the following code, which is not working:

// global
addEventListener("load", aInit, true);

function aInit()
{
   gBrowser.selectedBrowser.addEventListener("load", JSPrintOverride, true);
}

function JSPrintOverride ()
{
   var b = document.getElementById("content");

   b.contentWindow.print = function ()
   {
     alert("Print event traped!");
     // more processing here
   }

   return null;
}

-- 
Brian King
www.mozdev.org - free project hosting for the Mozilla community


More information about the Project_owners mailing list