Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

wie schaffe ich es, wenn ich ein Fenster mit JS gebaut habe, dass onclick dieser Inhalt ausgedruckt wird.


<script language="javascript">
function drucken ()
{
var win;
win=window.open("","NeuesFenster","width=700,height=500,scrollbars=yes");
win.document.writeln('<html>');
win.document.writeln('<head><title>Test</title></head>');
win.document.writeln('<body>');
win.document.writeln('Hallo');
win.document.writeln('<input type="button" value="Auftrag drucken" onclick="window.print ()">');
win.document.writeln('  <input type="button" value="Fenster schließen" onclick="window.close ()">');
win.document.writeln('</body>');
win.document.writeln('</html>');
}
</script>
[/code]

Aber bei Klick auf den Button Auftrag drucken passiert gar nichts. Was mache ich falsch?

Frank

Hi!

Du musst die Leerzeichen zwischen "window.print" und den "()" wegnehmen!

(genauso auch bei dem "window.close")

Gruß

Azrael

window.print() setzt voraus, das das zu druckende Fenster den Fokus hat. Da du offensichtlich das Fenster drucken willst, aus dem die Datei geöffnet wurde, gehts normalerweise mit opener.focus() und dann window.print().

Du brauchst also noch eine Funktion.

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.