问题
How to call Firefox printpreview using addon SDK. Newest SDK (1.16) not include printultis.js
Thank you somuch
回答1:
const { getMostRecentBrowserWindow } = require('sdk/window/utils');
var chromewin = getMostRecentBrowserWindow();
chromewin.PrintUtils.printPreview(chromewin.PrintPreviewListener);
回答2:
const BROWSER = 'navigator:browser' ;
var {Cc, Ci, Cu} = require("chrome");
const WM = Cc['@mozilla.org/appshell/window-mediator;1'].getService(Ci.nsIWindowMediator);
function getMostRecentBrowserWindow() {
return getMostRecentWindow(BROWSER);
}
exports.getMostRecentBrowserWindow = getMostRecentBrowserWindow;
function getMostRecentWindow(type) {
return WM.getMostRecentWindow(type);
}
exports.getMostRecentWindow = getMostRecentWindow;
var chromewin = getMostRecentBrowserWindow();
chromewin.PrintUtils.printPreview(chromewin.PrintPreviewListener);
This worked
来源:https://stackoverflow.com/questions/22703545/how-to-call-firefox-printpreview-using-addon-sdk