1

This is the first time I'm using the following Javascript coding in HTML5, but my printed page is always blank and shows "about:blank". Can anyone maybe help me? The button I coded is the following:

<a href="javascript:window.print()" class="icon-button print" target="LINK TO ANOTHER PAGE"><i class="icon-printer"></i><span></span></a>

5
  • Possible duplicate of How do I print different page using javascript/jQuery/ajax? Commented Oct 24, 2016 at 8:15
  • here is soution stackoverflow.com/questions/2578052/… Commented Oct 24, 2016 at 8:18
  • That didn't do the trick sadly. Commented Oct 24, 2016 at 8:22
  • Can you explain what "the trick" is? What do you want to happen? What actually happens? Commented Oct 24, 2016 at 8:29
  • I want the user to click the button so another page prints immediatly. Right now an empty tab opens and prints a blank page. Commented Oct 24, 2016 at 8:42

1 Answer 1

-1
the print function prints the content of the actual page, 
to print the other page you have to to execute the print on the load of that page like this :
<body onload="window.print()">
Sign up to request clarification or add additional context in comments.

8 Comments

So I changed my original page to <a href="link" class="icon-button print" target="_blank"><i class="icon-printer"></i><span></span></a> and amended the target page to <body class="size-1140 primary-color-green" onload="window.print()"> but it still prints a blank page. Any suggestions?
fill your page with somethings to see
I just tried this and it works normally : <body onload="window.print()"> <p>drgfhyghfgh</p> </body>
Let me link you to the files I've tried it on in Netbeans:
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.