Solved

Print html page

Posted on 2014-04-01
7
276 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
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).

839 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