Creating a print command for Ubiquity?
I want to create a simple 'print' command for ubiquity that will bring up the print dialog for the page i am viewing. i tried to use the javascript window.print(), but that only creates an error message "we are unable to print or print preview this page".
any idea what's going on? bear in mind, i am an extreme newbie.
any idea what's going on? bear in mind, i am an extreme newbie.
1
person has this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
-
Inappropriate?This is a simple command that should do the trick:
CmdUtils.CreateCommand({
name: "print",
execute: function() {
CmdUtils.getWindow().print();
}
});
EDIT:
Figured it might be a good idea to explain why this is needed - and though I'm not 100% sure, I figure the commands you write live in XUL, so window does not automatically point to the window of the page you're coming from...
That, and I happened to remember there was a function called getWindow() in CmdUtils :-P
take a look at chrome://ubiquity/content/cmdutils.js to see other functions available.. -
Inappropriate?this doesn't seem to have worked - it doesn't recognize getwindows as a function.
I’m sad
-
Inappropriate?Ahh, I see getWindow() is only available in the development version - here is a version that'll use getWindow if present, otherwise getWindowInsecure
CmdUtils.CreateCommand({
name: "print",
execute: function() {
if (CmdUtils.getWindow)
w = CmdUtils.getWindow();
else
w = CmdUtils.getWindowInsecure();
w.print();
}
});
-
Inappropriate?If available, your verb should use getWindow() instead of getWindowInsecure() - the next version of ubiquity will include getWindow() - so to avoid having to update your script later, you should probably use the method from my example, testing for the availability of getWindow()...
Loading Profile...




EMPLOYEE