[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


How to directly print a HTML file from another ?

Posted on 2004-11-12
Medium Priority
Last Modified: 2010-04-06
Hi all,

How can I do to print a HTML file from another one ?
For example, in the file index.html, I want a link to print directly the file "to_print.html" with or without confirmation.

Question by:Richard Coffre
  • 3
  • 2
LVL 12

Accepted Solution

minichicken earned 2000 total points
ID: 12568306

I think the easiest way to do it is to create a link or button on your index.html page that opens to_print.html in another window, and on your to_print.html run window.print(); on body load. So as soon as you click the print link or button it will popup the to_print.html page and will immediately ask to print.


<a href ="to_print.html" target="_blank">Print the other page</a> (link)
<input type ="button" value ="Print the other page" onclick="window.open('to_print.html');"> (button)

<body onload= "window.print();"> (have this as your body tag)

Author Comment

by:Richard Coffre
ID: 12570222
Can we automate the closing of the window after the printing ?
LVL 12

Expert Comment

ID: 12570468
you can use window.close(); but i think it will do a close confirm poup confirmation... i am not too sure how to avoid that...

Author Comment

by:Richard Coffre
ID: 12570732
On which event I can perform the window.close() ?
It's sure that a confirmation window will be prompted.
LVL 12

Expert Comment

ID: 12570782
can do this: <body onload= "window.print();window.close();">

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

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.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
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…
Suggested Courses

834 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