Print capability embedded within webpage

A

AL

How do I insert an icon that will allow a user to print the page they're
currently on? I know they can hit the printer icon above the toolbar but
wanted to simplify the process for someone who needed to print the current
page...

Thanks - AL
 
N

Nicholas Savalas - http://savalas.tv

Dear Al,
Simple. This is not the only answer, but it is cross-browser friendly -
this is from the good folks at DynamicDrive -
http://dynamicdrive.com/dynamicindex9/other1.htm - Directions: Simply
copy the below into the <body> section of your page:

<SCRIPT Language="Javascript">

/*
This script is written by Eric ([email protected])
For full source code, installation instructions,
100's more DHTML scripts, and Terms Of
Use, visit dynamicdrive.com
*/

function printit(){
if (window.print) {
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>

Good luck, Al.

Nicholas Savalas - http://savalas.tv
 
R

rfr

But . . what about the option to print a printer friendly version. Usually
this version is without header, footers, advertisements, images, etc.

How is this done?
 

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