Solved

Print html page

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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ability to create nested list on the UI using PHP, HTML, Javascript 7 57
Responsive Font Size 6 45
HTML5 storage and web apps 11 44
Use "if not" in a condition 2 18
This article discusses four methods for overlaying images in a container on a web page
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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 …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

740 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