navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Print This Page Button

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Community >> OutFront Discoveries >> Print This Page Button
Page: [1]
 
hhammash

 

Posts: 1064
Joined: 8/19/2002
Status: offline

 
Print This Page Button - 9/29/2002 17:53:06   
How to Make a Button That Prints the Page


This script will create a " Print Button" that when clicked on your site will print the page it is placed on. It has been tested in MSIE 4 and 5 and NN 4+ browsers.

This entire script below goes in the <BODY> section where you want your button to appear on your page.


<SCRIPT Language=" Javascript" >

function printit(){
if (NS) {
window.print() ;
} else {
var WebBrowser = ' <OBJECT ID=" WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID=" CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" ></OBJECT>' ;
document.body.insertAdjacentHTML(' beforeEnd' , WebBrowser);
WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box WebBrowser1.outerHTML = " " ;
}
}
</script>

<SCRIPT Language=" Javascript" >
var NS = (navigator.appName == " Netscape" );
var VERSION = parseInt(navigator.appVersion);
if (VERSION > 3) {
document.write(' <form><input type=button value=" Print this Page" name=" Print" onClick=" printit()" ></form>' );
}
</script>


Regards
Hisham

Charles W Davis

 

Posts: 1725
Joined: 3/7/2002
From: Henderson Nevada USA
Status: offline

 
RE: Print This Page Button - 9/30/2002 13:32:50   
Hisham,

As you indicated the print button does work in IE and NN. However, it just stares back at you in Opera 6.

_____________________________

Enjoy! It' s your endeavor!
http://www.anthemwebs.com

(in reply to hhammash)
abbeyvet

 

Posts: 5095
From: Kilkenny Ireland
Status: offline

 
RE: Print This Page Button - 9/30/2002 20:58:07   
This one is a bit shorter and as far as I know works in all browsers:

<Script language=" JavaScript" >
if (window.print) {
document.write(' <form>'
+ ' <input type=button name=print value=" Print Page" '
+ ' onClick=" javascript:window.print()" > </form>' );
}
</script>

_____________________________

Katherine

:: InKK Design :: InKK Domains

(in reply to hhammash)
imouthere

 

Posts: 401
Joined: 1/23/2002
From: Greenville NC USA
Status: offline

 
RE: Print This Page Button - 9/30/2002 22:23:12   
I' ve always just used this text link print ...
quote:

<a href=" #" onClick=" window.print()" >Print Page</a>


Best of Luck,

_____________________________

Scott
:)

(in reply to hhammash)
ccmoran

 

Posts: 14
From: Mountain View, CA USA
Status: offline

 
RE: Print This Page Button - 10/5/2002 11:20:35   
How is a " printer friendly" version of the hyothetical page set up?

Cathy

(in reply to hhammash)
abbeyvet

 

Posts: 5095
From: Kilkenny Ireland
Status: offline

 
RE: Print This Page Button - 10/5/2002 12:01:06   
It really depends how your original pages are created.

If they are plain HTML then the only way is to manually create an extra page. If they are called from a database then you can just set up a simple page that also calls them.

If it was just a few pages you could put the content into an include page and include it in both the standard and for printing pages. At least that way you would have only one page to edit if you wanted to change something.

_____________________________

Katherine

:: InKK Design :: InKK Domains

(in reply to hhammash)
monsieurrick

 

Posts: 4
Joined: 7/4/2002
Status: offline

 
RE: Print This Page Button - 10/17/2002 15:42:48   
i was wondering if you could modify this script to limit the number of prints as in one test and one actual. i have a need for such. thanx, rick

(in reply to hhammash)
hhammash

 

Posts: 1064
Joined: 8/19/2002
Status: offline

 
RE: Print This Page Button - 10/23/2002 13:33:17   
Hi,

Thank you all for your input.

You made it a rich subject.

This back button will not be put on the index page. I usually put it on my site where the reader views series of pictures or reads more than one page. The second page will send him back to the first page where he/she came from. When the user reaches the first page he/she will not have the button.

Thanks you again for your ideas. They are all useful.

Regards
Hisham

(in reply to hhammash)
Avick

 

Posts: 181
From: Ireland
Status: offline

 
RE: Print This Page Button - 1/20/2005 6:55:27   
I am using the javascript:window.print() command along with a print style sheet (for screen I use the sheet screen.css and for print I use print.css)

Is there any way I can use the javascript:window.print() to preview the page. I have tried
javascript:window.print() but its not working. (worth a try though :))

I think I recall seeing this before but can't remember where.



_____________________________

Alan
http://www.newebirl.net

(in reply to hhammash)
Kitka

 

Posts: 2515
Joined: 1/31/2002
From: Australia
Status: offline

 
RE: Print This Page Button - 1/20/2005 7:16:06   
Avick,
You might try:
<html>
<head>
<title>Print Preview</title>
<script>
function printpr()
{
var OLECMDID = 7;
/* OLECMDID values:
* 6 - print
* 7 - print preview
* 1 - open window
* 4 - Save As
*/
var PROMPT = 1; // 2 DONTPROMPTUSER
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(OLECMDID, PROMPT);
WebBrowser1.outerHTML = "";
}
</script>
</head>
<body>
<form>
<input type='button' value="Print Preview" onclick="printpr();">
</form>
</body>
</html>


_____________________________

Kitka
**It is impossible to make anything foolproof because fools are so ingenious.**


(in reply to Avick)
Avick

 

Posts: 181
From: Ireland
Status: offline

 
RE: Print This Page Button - 1/20/2005 7:39:54   
Thanks Kitka.

It worked fine when I put it in but I decided to take it out as I want to keep the JS to a min.

Worth keeping on file



_____________________________

Alan
http://www.newebirl.net

(in reply to Kitka)
Karl

 

Posts: 172
From: Chucktown, SC
Status: offline

 
RE: Print This Page Button - 1/20/2005 8:07:41   
All,

I usually use:
<a id="gotoprint" href="javascript:window.print();" title="Print page">Print page</a>


Cathy,

In response to your question:

quote:

How is a " printer friendly" version of the hyothetical page set up?


When building your site, you can link to an external style sheet while setting the media to "print".

Par example: 
<style type="text/css" media="print">@import "print.css";</style>


Have a look at this post in the CSS Forum: Print pages using CSS

HTH,

Karl

_____________________________

Create, validate, and communicate!
Adonnis Networks

(in reply to ccmoran)
d a v e

 

Posts: 4087
Joined: 7/24/2002
From: England (but live in Finland now)
Status: offline

 
RE: Print This Page Button - 1/20/2005 9:20:57   
doesn't averyone have a print button/menu commanc/shortcut in their browser ?!

;)

i've always been at a loss as to why people put those on their pages, but hey that's me!

_____________________________

David Prescott
Gekko web design

(in reply to Karl)
Avick

 

Posts: 181
From: Ireland
Status: offline

 
RE: Print This Page Button - 1/20/2005 9:25:30   
Most people put them on there pages because most web pages don't fit on A4 or Letter paper.
When you put a button or link like this on the page you are telling the visitor. This page was designed to be printed on to paper.



_____________________________

Alan
http://www.newebirl.net

(in reply to d a v e)
d a v e

 

Posts: 4087
Joined: 7/24/2002
From: England (but live in Finland now)
Status: offline

 
RE: Print This Page Button - 1/20/2005 9:35:00   
of course - forgot that, but with a print style sheet there's no need :)

_____________________________

David Prescott
Gekko web design

(in reply to Avick)
Avick

 

Posts: 181
From: Ireland
Status: offline

 
RE: Print This Page Button - 1/20/2005 11:10:39   
But how do they know you have a print stylesheet unless you put *Print Version* on your site :)

Most people would just look at the page and say "Well I'm not printing that"


Forgot this but:
Have a look at my terms page http://www.newebirl.net/terms.htm now click the print version and print the page (2pages) see the differance.

_____________________________

Alan
http://www.newebirl.net

(in reply to d a v e)
d a v e

 

Posts: 4087
Joined: 7/24/2002
From: England (but live in Finland now)
Status: offline

 
RE: Print This Page Button - 1/20/2005 12:10:29   
fair point - but what if they have js disabled? well then i guess they just print and the styleheet takea care of it anyway :)

nice site by the way

_____________________________

David Prescott
Gekko web design

(in reply to Avick)
Avick

 

Posts: 181
From: Ireland
Status: offline

 
RE: Print This Page Button - 1/20/2005 16:49:55   
Thanks David

and your right, if JS is disabled that the sheet still works.
The words print version still apper in the screen version regardles of the JS so they know thy can print that page.

So now you have seen the light are we going to see a print version on your site :)

_____________________________

Alan
http://www.newebirl.net

(in reply to d a v e)
d a v e

 

Posts: 4087
Joined: 7/24/2002
From: England (but live in Finland now)
Status: offline

 
RE: Print This Page Button - 1/21/2005 0:17:38   
my 'site' (in my sig) is so small that i don't need a print version - thw whole thing fits on a stamp (well almost) i need to finish it one day. i did do a print style sheet for my last site
http://flaxandhemp.bangor.ac.uk/

_____________________________

David Prescott
Gekko web design

(in reply to Avick)
Avick

 

Posts: 181
From: Ireland
Status: offline

 
RE: Print This Page Button - 1/21/2005 5:11:38   
A welsh site, very nice. Had to click the English section as I don't know welsh.
Fantastic Country. Stopped off there on my way to Coventry. Breath Taking!!!



_____________________________

Alan
http://www.newebirl.net

(in reply to d a v e)
d a v e

 

Posts: 4087
Joined: 7/24/2002
From: England (but live in Finland now)
Status: offline

 
RE: Print This Page Button - 1/21/2005 7:20:16   
i lived in bangor (North Wales, near Snowdon) for 4 years and it's really nice. and rainy, but nice

_____________________________

David Prescott
Gekko web design

(in reply to Avick)
Page:   [1]

All Forums >> Community >> OutFront Discoveries >> Print This Page Button
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts