Results 1 to 13 of 13

Thread: A Javascript Print function???

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    A Javascript Print function???

    A friend of mine told me that there exists a print function in javascript, which brings up the printer dialog box, so you can print the web page.

    Is this true? I did a search, and found nothing. If it exists, what is it?

  2. #2
    Hyperactive Member progressive's Avatar
    Join Date
    Sep 2001
    Location
    Manchester, UK
    Posts
    404
    Code:
    window.print();
    This opens up the printer window.
    A quick test on the browsers I have on my system (NN6.2, Mozilla, Opera, NN4.7, IE5.5) revealed that the only one that doesn't understand this code is Opera so I don't know if there is a diferent command for Opera or not!

    4 out of 5 aint bad though

  3. #3

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Originally posted by progressive
    Code:
    window.print();
    thank you!

  4. #4

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Opera is irrelevant at this stage.

  5. #5
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    I don't think it's supported in Opera at present but you could try different methods to get around it. such as document.print() or just plain print().
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  6. #6
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    I use

    Code:
    if (window.print) document.writeln('<a href="#" onclick="window.print(); return false;">Print<\/a>');
    or something to that extent That way it will only offer printing if it's avaliable.

  7. #7
    Hyperactive Member progressive's Avatar
    Join Date
    Sep 2001
    Location
    Manchester, UK
    Posts
    404
    good thinking

  8. #8
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Yeah but I only copied from other people, so not really

  9. #9
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    takes a true hero like Penfold to admit something like that

  10. #10
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    oh and I just tried it in Opera, it works fine

  11. #11

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Thanks for the Opera thing.

    I can safely assume it'll work on Mozilla?

  12. #12
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    yeah, works in Mozilla. Well, i assume so because it's a EMCA standard...
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  13. #13
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Originally posted by chrisjk
    takes a true hero like Penfold to admit something like that
    Crumbs, thanks DM. [Penfold, shush]

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