Solved

Print html page

Posted on 2014-04-01
7
274 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 83

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 83

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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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 83

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 83

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

813 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

16 Experts available now in Live!

Get 1:1 Help Now