print page onload

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ramkrishnatiwari
    New Member
    • Jul 2007
    • 1

    #1

    print page onload

    I want to print the page when page is load but i do not work why pl. help.

    enter this javascript but could not any response.

    function printpage()
    {
    window.print();
    }


    <body OnLoad="printpa ge()">

    even this when i want to alert dialouge box it would also not give any response

    <body onload="alert(' hello')">
  • mwasif
    Recognized Expert Contributor
    • Jul 2006
    • 802

    #2
    Make sure you dont have any javascript errors on the page and use this code at the end of the page instead.
    [CODE=javascript]<script language="javas cript">
    window.print();
    </script>[/CODE]

    If you are still unable to make it to work then post your page code.

    Comment

    • pbmods
      Recognized Expert Expert
      • Apr 2007
      • 5821

      #3
      Heya, ramkrishnatiwar i. Welcome to TSDN!

      I'm going to go ahead and move this thread to the JavaScript forum, where one of our resident Experts will be more likely to see it.

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        hi ...

        make sure your page looks like the following example:

        [HTML]
        <html>
        <script type="text/javascript">
        function do_onload() {
        alert('hello');
        }
        </script>
        <body onload="do_onlo ad();">
        </body>
        </html>
        [/HTML]

        use type in the script-tag ... language is deprecated so don't use it ...

        kind regards

        Comment

        Working...