Habe mal wieder mit JavaScript gespielt, heraus kam eine Methode, direkt Texte auf einem Drucker auszugeben (Ok, der System Druckdialog ließ sich nicht umgehen, ist aber auch besser so!)
String.prototype.print = function(){ var ifr = document.createElement('iframe'); ifr.style.visibility = 'hidden'; document.body.appendChild(ifr); ifr.contentWindow.document.open(); ifr.contentWindow.document.write(this); ifr.contentWindow.print(); ifr.contentWindow.document.close(); }; |
Ein paar Beispiele:
"Hello World!".print(); "Hello <strong>World</strong>!<br>This is a test!!".print() |
Dieser Codeschnipsel habe ich bislang nur unter FF getestet, funktionierte!
Played again a bit with JavaScript and created a small code-snippet which let you print out a String on a printer without opening a popup-window.
String.prototype.print = function(){ var ifr = document.createElement('iframe'); ifr.style.visibility = 'hidden'; document.body.appendChild(ifr); ifr.contentWindow.document.open(); ifr.contentWindow.document.write(this); ifr.contentWindow.print(); ifr.contentWindow.document.close(); }; |
Two small examples:
"Hello World!".print(); "Hello <strong>World</strong>!<br>This is a test!!".print() |
I have tested it only with Firefox, worked good for me.









