Solved

Print html page

Posted on 2014-04-01
7
278 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

752 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