How do I insert a "Print" button in Front Page?

G

Guest

I'm trying to insert a push button, which will print the current page from a
web page. Can anyone give me any idea on how to do this?
 
T

Trevor L.

Insert this HTML code

<input type="button" name="Print" Value="Print this page"
onclick='window.print();'>

You may need to have a special style for printing

If you do, use something like this in the head section
<style type="text/css" media="print">
body {background: white ;} /*...etc....*/
</style>
--
Cheers,
Trevor L.
Website: http://tandcl.homemail.com.au


I choose Polesoft Lockspam to fight spam, and you?
http://www.polesoft.com/refer.html
 
M

Murray

That suggestion fails on Mac/IE5x. This is the best you can do -

Put this in the head of the document -

<script type="text/javascript">
function print_page(where){
var is_mac=(navigator.platform.indexOf("ac") != -1);
(document.all && is_mac)?
alert("Select \"Print\" from the menu") : where? where.window.print() :
window.print();
}
</script>

Put this in the body of the document -

<a href="javascript:print_page()">Print this</a>
 
T

Trevor L.

Murray,

As always you are helpful. I appreciate that you look at cross-browser
issues

I put your JS in <head> for a page I wanted to print but altered the HTML to
<input type="button" name="Print" Value="Print this page"
onclick='print_page();'>
so that it looks a bit prettier.

--
Cheers,
Trevor L.
Website: http://tandcl.homemail.com.au


I choose Polesoft Lockspam to fight spam, and you?
http://www.polesoft.com/refer.html
 
M

Murray

You could even do this -

<button type="button" name="Print" value="Print" onClick="print_page();">

and it doesn't have to be in a <form>.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top