Welcome to WebmasterWorld Guest from 54.196.244.45

Forum Moderators: incrediBILL

Message Too Old, No Replies

Printing from a webpage

how do you set printing parameters etc..

     

Ciall

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

Inactive Member
Account Expired

 
 


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.

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

Senior Member

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:May 26, 2000
posts:37301
votes: 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

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 18, 2001
posts:1437
votes: 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.

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

Preferred Member

10+ Year Member

joined:Feb 8, 2001
posts:582
votes: 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>

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 8, 2001
posts:690
votes: 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

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

Inactive Member
Account Expired

 
 


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)
8:23 pm on May 7, 2001 (gmt 0)

Preferred Member

10+ Year Member

joined:Mar 29, 2001
posts:406
votes: 0


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

Xoc

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 18, 2001
posts:1437
votes: 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

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

Full Member

joined:June 21, 2000
posts:339
votes: 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

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 18, 2001
posts:1437
votes: 0


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

GWJ

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

Full Member

joined:June 21, 2000
posts:339
votes: 0


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

Brian