Solved

Print html page

Posted on 2014-04-01
7
272 Views
Last Modified: 2014-04-02
I have a page that I want to print.  I have a "print" button that goes to another page without the menus, header, etc.  How do I throw this "duplicate" page to the printer?
0
Comment
Question by:breeze351
  • 4
  • 3
7 Comments
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39970345
The most common way is to put a javascript print button on that page.  If you are looking to 'automatically' print that page on a user's computer, that isn't going to happen.  You have to go thru the print dialog so they have the choice to say no.
0
 

Author Comment

by:breeze351
ID: 39970938
The reason for the 2nd page is that there are up to 4 different print formats.
I if recreate the 1st page for format #1, what code do I need to add? Would this work:



<body>
echo "something"
</body>

<script>
function My_Print ()
{
      window.print()
}
</script>
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39970965
If you want it to bring up the print dialog when the page loads, you can do this.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>Page to Print</title>
<script>
function My_Print ()
{
      window.print()
}
</script> 

</head>
<body onload="My_Print();">
echo "something"

</body>
</html>

Open in new window

0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:breeze351
ID: 39973056
Ok, the print works.  The next question is how do I not display the data on the screen and return to the previous page?

I'm more of a database guy and got stuck with this HTML stuff.
Thanks
Glenn
0
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 39973102
You can not Not display the page.  This is HTML in your web browser, not a desktop app.  You can only print a page that is displayed on your screen.  Return to the previous page?  Click on the back button.
0
 

Author Comment

by:breeze351
ID: 39973149
Thanks. I figured this out already.  I thought that there might be another way that I didn't know of.
Glenn
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39973177
No, I'm afraid that's the way it works.  Glad to help, thanks for the points.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now