Link called: Print this page.
Hello all.
Simply put is I want a link that is called "Print This Page"
What I am trying to figure out is how to make that link, when clicked, open a new window (with the original page in a printable format - no pics no color) and have that pop up window page automatically open the print function on the user's computer.
I thought I had the basics:
HREF="http://www.mysite.com/newpage.htm" onclick="newWindow = window.open("printable.htm", "print", "toolbar,resizable,scrollbars"); newWindow.focus(); return false;">
But it doesn't work!
I appreciate all the help you could give.
Thanks
Bob
http://www.contesthound.com
Contests and Sweepstakes Directory.
Gem posted this at 17:25 — 25th June 2000.
They have: 16 posts
Joined: Jun 2000
If your site is databased it would just be a matter of calling the content with a plain vanilla template. For example if you have a review site your review for a camera may be someurl.com/review.php?id=05. This page would contain all your fancy pics and layout. Each review would be contained in a database and given an id (in the example above id=05).
Your "print this page" link would be someurl.com/print.php?id=05. The template print.php would just display plain white background and black text.
It would take quite a bit of work to set up a databased site, it all depends on how large and how detailed you want to get, but in the long run it would make maintaining your site a lot easier.
There may be a way to do this with javascript but I don't know how. I am only telling you the way I know is possible.
------------------
Gem
Summer's here- OH YEAH!
Gem
S I F O X - Giving The Internet A Makeover
Suzanne posted this at 21:08 — 25th June 2000.
She has: 5,507 posts
Joined: Feb 2000
window.print() is what you need.
At least that's what JavaScript the Definitive Guide says. Page 736, but no other instructions.
Suzanne
------------------
Zero Cattle
Suzanne
Tables DeMystified
Vincent Puglia posted this at 22:06 — 25th June 2000.
They have: 634 posts
Joined: Dec 1999
Hi,
yes, window.print() works for NN; IE requires an activeX control (webBrowser), whose object ID I do not have at the moment. (I recall having posted the command/script here or on the Javascript City boards; at any rate, I'll put it up asap.)
However, both commands tend to print the page itself (graphics, url info, etc), much as the browser's FILE-Print command. If you want a "printer-friendly" solution, you may need to direct the link to a text-only page.
Javascript City
Vinny
[This message has been edited by Vincent Puglia (edited 25 June 2000).]
Where the world once stood
the blades of grass cut me still
Arielladog posted this at 04:31 — 26th June 2000.
They have: 122 posts
Joined: Jun 1999
I had to do this, also before. What I did was first open another printable version page that I had made. With window.open('theprintversion.html') and you could make it scroll bars , whatever. Then, I made the print version of the page and put this script in the head.
<head>
<SCRIPT>
function printit(){
if (window.print) {
window.print() ;
} else if (document.all) {
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, 1);//Use a 1 vs. a 6 for a prompting dialog box
WebBrowser1.outerHTML = "";
}
}
</script>
</heaD><BODY onload="printit();setTimeout('self.close',10000)">
note that if you change the 1 to a 6, you won't get a dialog box when printing from IE. THe page will automatically begin printing without the user's consent (other than the fact that they click on that page)...sneaky, ain't it¿
Moderate at JavaScriptCity Forums
Vincent Puglia posted this at 17:14 — 27th June 2000.
They have: 634 posts
Joined: Dec 1999
Thanks Arielladog Kept looking for it, but couldn't find it. Then saw your post on wsabstract & thought Great! I'll cut&paste & bring it here.
Vinny
------------------
my site:GrassBlade: cut&paste javascript
moderator at:The Javascript Place
Javascript City
Where the world once stood
the blades of grass cut me still
Arielladog posted this at 23:04 — 27th June 2000.
They have: 122 posts
Joined: Jun 1999
hehe
Vincent Puglia posted this at 00:02 — 28th June 2000.
They have: 634 posts
Joined: Dec 1999
Hi Arielladog,
just cut&pasted it for someone in javascript city.
Vinny
------------------
my site:GrassBlade: cut&paste javascript
moderator at:The Javascript Place
Javascript City
Where the world once stood
the blades of grass cut me still
artnow posted this at 01:48 — 28th June 2000.
They have: 32 posts
Joined: May 2000
Well I do appreciate all the info. I haven't had a chance to use it yet.
Thanks again
Bob
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.