Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Auto Print...... Help!

  1. #1
    Join Date
    May 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Auto Print...... Help!

    hello.... i'm asking to write a system that can auto print the webpage without pop up any dialog box.

    the problem is i totally not idea what source code can i use to write for it.
    if i writing this system by using HTML + javascript, can i success to done it?

    if can, how to write the coding of html to run it? can teach me how to do it?

    i'm really headache about this task. hope can gets some from you all here.

    Thanks.................

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    file > print in your browser window. if you are looking to add a link to a page that they can click on to print, I believe its something like

    Code:
    <a href="javascript:print()">Print Page</a>

  3. #3
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Insert the following code into your <head> once the your page loads completely it will start the printing automatically.
    Code:
    <script type="text/javascript">
         window.onload = function() {
                 window.print(); 
         }
    </script>

  4. #4
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Watch out for overwriting onload event handlers, for example:
    Code:
    function abc() {};
    function xprint() {window.print();}
    window.onload = abc;xprint;
    Add a semicolen after each function, if needed.
    - Mike

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I think you all missed the key criterion:
    without pop up any dialog box.
    This can't be done. It may be possible with Java or ActiveX, but then you'd have a dialogue for that instead.

    mburt, that's equivalent to:
    Code:
    window.onload = abc;
    
    xprint;
    You mean:
    Code:
    window.onload = function() {
      abc();
      xprint();
    };
    Last edited by Twey; 05-17-2007 at 11:10 AM.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    May 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by codeexploiter View Post

    Code:
    <script type="text/javascript">
         window.onload = function() {
                 window.print(); 
         }
    </script>
    what is the purpose and why must write the window.onload....
    can i direct write the window.print()?

    i try already but i still can run.

  7. #7
    Join Date
    May 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey View Post
    I think you all missed the key criterion:This can't be done. It may be possible with Javascript or ActiveX, but then you'd have a dialogue for that instead.
    Thread:

    it's really can't done by using html and javascript?

    Then do u have any suggestion of the coding to me so that can auto print the webpage without have pop up any dialog box or dialogue for that instead.

    Thanks.........!!

  8. #8
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Please don't, you'll (for lack of a better expression) piss off your users.
    If this is meant for your school/buisness/etc, then having the dialouge box isn't that bad, its only an extra click.
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  9. #9
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    It's simply not possible. No matter what you try, some kind of dialogue will be involved at least once.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  10. #10
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    If you are trying to bypass the Printer Dialogbox then Twey is absolutely correct it is impossible; you won't be able to bypass the printer option dialogbox. I think this is some kind of security restriction otherwise If I want I can make my website users printer working without much trouble.

    I wonder what you are trying to achieve in this case? If you provide a print link then your users need to take a printout they can do that. Why do you insisting on taking your page's printout?

    what is the purpose and why must write the window.onload....
    can i direct write the window.print()?
    You are correct but in my approach only after loading the complete window content the printing will start.

Bookmarks

Posting Permissions

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