Results 1 to 13 of 13

Thread: Printing a url

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224

    Printing a url

    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

  2. #2
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    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.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  3. #3
    Junior Member
    Join Date
    Dec 2000
    Location
    London
    Posts
    25
    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.

  4. #4
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    i don't think that window.print() works in netscape...but what else is new!

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  5. #5
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    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.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  6. #6
    Junior Member
    Join Date
    Dec 2000
    Location
    London
    Posts
    25
    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!

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224
    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

  8. #8
    Junior Member
    Join Date
    Dec 2000
    Location
    London
    Posts
    25
    I've found the code you need and just worked out how to attach stuff!
    Last edited by fsystem; May 11th, 2001 at 11:18 AM.

  9. #9
    Junior Member
    Join Date
    Dec 2000
    Location
    London
    Posts
    25
    this attachment should do the job...
    Attached Files Attached Files

  10. #10
    kayoca
    Guest

    landscape

    and how about setting the landscape propertie to default?

  11. #11
    Lively Member benski's Avatar
    Join Date
    Sep 1999
    Location
    UK
    Posts
    126
    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?

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224
    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

  13. #13
    Junior Member
    Join Date
    Dec 2000
    Location
    London
    Posts
    25
    Don't know if this is any good to you...

    http://javascript.internet.com/messages/print-page.html

    Hope it helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width