homepage Welcome to WebmasterWorld Guest from 23.22.97.26
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
Printing from a webpage
how do you set printing parameters etc..
Ciall




msg:607144
 5:07 pm on May 1, 2001 (gmt 0)

You guys are great, i appreciate the help i've gotten so far.

New question, where could i find code that would allow me to create a print button that would function properly. Also are there options available for automatically customizing the print setup

For instance, i want to be able to have someone hit the print button and it will print the document with a smaller font (the web version uses larger fonts for readability), with no background etc. I know a way around parts of this but ideally i could make it all in a single button with some coding to simplify the process.

 

tedster




msg:607145
 4:27 am on May 2, 2001 (gmt 0)

Welcome to the forum, Ciall. Printing control is a challenge (evidenced by the fact that you're not exactly flooded with responses so far.)

The CSS2 recommendation has support for a group of printing controls, but CSS2 doesn't enjoy much browser support at this time. My solution to date has been to create pdf docs for printing.

Maybe someone else will come along who has delved a bit deeper than I have.

Xoc




msg:607146
 6:57 am on May 2, 2001 (gmt 0)

The other solution to using pdf files is to have a link to a separate but similar web page for printing that is customized to work well on standard paper. However, if you do this, you might consider using the following meta tag in the head of the print page:

<meta name="ROBOTS" content="NOINDEX,NOFOLLOW"></meta>

This will assure that a spider doesn't treat the second page as a mirror of the first and penalize you for spamming.

nicebloke




msg:607147
 8:36 am on May 2, 2001 (gmt 0)

>New question, where could i find code that would allow me to create a print button that would function properly.

Not sure if this is what you're after - and it's PC only..but it gives you a "print" button:

<script language="Javascript">

/*
This script is written by Eric (Webcrawl@usa.net)
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>

knighty




msg:607148
 9:44 am on May 2, 2001 (gmt 0)

>>document.write('<form><input type=button value="Print this Page" name="Print" onClick="printit()"></form>');

instead of the above you can just use:

document.write("<a href='javascript:printit()'>Print This Page</a>");

or an image if you prefer

Ciall




msg:607149
 12:17 pm on May 2, 2001 (gmt 0)

my existing thought was to create duplicate documents that have no background/proper formatting and refer to that document when the print button is pressed.
I cannot get away with pdf files since there will be changes made to these documents on a semi-regular basis and that just complicats updating the files.
I will try the scripts you guys suggested and let you know if i have any luck :o)

Eric_Lander




msg:607150
 8:23 pm on May 7, 2001 (gmt 0)

Is there any way to make this usable script functional for MAC users?

Xoc




msg:607151
 9:24 pm on May 7, 2001 (gmt 0)

Unfortunately, the script that nicebloke showed uses features only found in IE running under Windows. The code also has a bug, because it sets a variable determining if it is running NetScape, but then never uses it. You really only want to run the code if it is IE.

Imagine this: suppose that if I could print a page from JavaScript without intervention. Then you hit my web page which on the onLoad starts printing p*rno pictures on your printer. So there certainly can't be a way that can't be restricted by the browser security settings or require user approval to print.

GWJ




msg:607152
 11:15 am on May 10, 2001 (gmt 0)

>>it's a good idea to make a separate, printer-friendly page.

Would SE's ding you for duplicate content/pages? If so would an edit to the robots.txt and a no follow tag on the page help?

Brian

Xoc




msg:607153
 4:48 pm on May 10, 2001 (gmt 0)

The meta tag that I suggested above should keep the search engine from indexing that page. It will still follow hyperlinks.

GWJ




msg:607154
 12:22 pm on May 11, 2001 (gmt 0)

Whoops, time to get new glasses or laser surgery ;).

Brian

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved