|
| |
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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.**
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
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
|
|
|