A friend of mine told me that there exists a print function in javascript, which brings up the printer dialog box, so you can print the web page.
Is this true? I did a search, and found nothing. If it exists, what is it?
Printable View
A friend of mine told me that there exists a print function in javascript, which brings up the printer dialog box, so you can print the web page.
Is this true? I did a search, and found nothing. If it exists, what is it?
This opens up the printer window.Code:window.print();
A quick test on the browsers I have on my system (NN6.2, Mozilla, Opera, NN4.7, IE5.5) revealed that the only one that doesn't understand this code is Opera so I don't know if there is a diferent command for Opera or not!
4 out of 5 aint bad though ;)
thank you!Quote:
Originally posted by progressive
Code:window.print();
Opera is irrelevant at this stage.
I don't think it's supported in Opera at present but you could try different methods to get around it. such as document.print() or just plain print().
I use
or something to that extent :D That way it will only offer printing if it's avaliable.Code:if (window.print) document.writeln('<a href="#" onclick="window.print(); return false;">Print<\/a>');
good thinking :D
Yeah but I only copied from other people, so not really ;)
takes a true hero like Penfold to admit something like that ;)
oh and I just tried it in Opera, it works fine
Thanks for the Opera thing.
I can safely assume it'll work on Mozilla?
yeah, works in Mozilla. Well, i assume so because it's a EMCA standard...
Crumbs, thanks DM. [Penfold, shush]Quote:
Originally posted by chrisjk
takes a true hero like Penfold to admit something like that ;)