Click to See Complete Forum and Search --> : Printing a url
kanejone
May 10th, 2001, 10:33 AM
Hi guys
Is there anyway in JavaScript to print a link.
eg. window.Print (www.netscape.net).
I want the target page to go to the printer??
Please help with this, I'm really stuck
JoshT
May 10th, 2001, 10:57 AM
There is a window.print() that prints the current page "as if the user had clicked the browser's print button." I doubt you can print another page or site, and I doubt the validity of window.print(), as if a user wants to print a page, they can print it themselves, else you're just hijacking their printer.
fsystem
May 10th, 2001, 01:48 PM
It is possible, I can't find the code for it at the moment but I'll have a look.
As for the usefulness, you can't get around the Windows print dialog box but it does automate printing as much as possible and of course you can control navigation etc.
sail3005
May 10th, 2001, 10:10 PM
i don't think that window.print() works in netscape...but what else is new!
JoshT
May 11th, 2001, 06:46 AM
i don't think that window.print() works in netscape...but what else is new!
I got it out of the Rhino book. I wouldn't be surprised if Netscape disabled it in later versions for security reasons. There's no good reason why a web author should have script access to the user's print functions.
fsystem
May 11th, 2001, 07:30 AM
I agree if you're talking about normal web pages but I write many web based applications that require automated printing and navigation. It does have it's uses!
kanejone
May 11th, 2001, 10:01 AM
That's what I'm writing. I've got an application that generates reports. there could be upto 20 reports at a time. I really need to know if anyone has any code that can automate this printing.
I'd really appreciate anyone that may be able to help me with this. I've beenstuck for about three days just on this problem.
Thanks again
JK
fsystem
May 11th, 2001, 11:03 AM
I've found the code you need and just worked out how to attach stuff!:)
fsystem
May 11th, 2001, 11:16 AM
this attachment should do the job...
kayoca
Aug 1st, 2001, 07:57 AM
and how about setting the landscape propertie to default?
benski
Aug 1st, 2001, 09:25 AM
Woah! That code looks horrible! Dynamic Object embedding, just to automate some printing??
Erm, as to the suitablility for what you require, I don't know. Do you not want to be able to print all the pages one after the other?
kanejone
Aug 2nd, 2001, 05:34 AM
The code actually works which is great(Thanks fsystem). But it has problems with IE4.0. It is pretty complicated for what it does.
Just out of interest, any suggestions on how to do it a different way??
Thanks
JK
fsystem
Aug 2nd, 2001, 10:25 AM
Don't know if this is any good to you...
http://javascript.internet.com/messages/print-page.html
Hope it helps.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.