html javascript print command

Discussion in 'HTML' started by tigeressal, Apr 12, 2008.

  1. tigeressal

    tigeressal Guest

    hi,
    im new to this group but ill be direct to the point.

    im tryin to create a simple webpage that will print the contents of
    the webpage to a printer on a client side machine.

    i know the command is ' window.print() ' and that i can have it in
    the ' onload() ' statement so that the print dialouge appears prior to
    printing.

    here my question. how do i eliminate the Header and Footer information
    that is automatically generated by the webpage?(i.e. the website name
    at the top, and the location url at the bottom)

    any help appreciated.

    regards

    rak
    tigeressal, Apr 12, 2008
    #1
    1. Advertising

  2. tigeressal wrote:
    > hi,
    > im new to this group but ill be direct to the point.
    >
    > im tryin to create a simple webpage that will print the contents of
    > the webpage to a printer on a client side machine.
    >
    > i know the command is ' window.print() ' and that i can have it in
    > the ' onload() ' statement so that the print dialouge appears prior to
    > printing.


    I wouldn't recommend it. Folks who browse the web expect to *see* a page
    when it loads, if they want to print it they will click print from their
    browser. Anyway what if they don't have a printer? Maybe they are view
    the page from on of those iPhones...


    > here my question. how do i eliminate the Header and Footer information
    > that is automatically generated by the webpage?(i.e. the website name
    > at the top, and the location url at the bottom)


    You cannot, those are user settings on the browser. You cannot script them.


    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Apr 12, 2008
    #2
    1. Advertising

  3. tigeressal

    PW Guest

    "tigeressal" <> wrote in message
    news:...
    > hi,
    > im new to this group but ill be direct to the point.
    >
    > im tryin to create a simple webpage that will print the contents of
    > the webpage to a printer on a client side machine.
    >
    > i know the command is ' window.print() ' and that i can have it in
    > the ' onload() ' statement so that the print dialouge appears prior to
    > printing.
    >
    > here my question. how do i eliminate the Header and Footer information
    > that is automatically generated by the webpage?(i.e. the website name
    > at the top, and the location url at the bottom)
    >
    > any help appreciated.
    >
    > regards
    >
    > rak





    First, create a style like this ...
    <style type="text/css">
    <!--
    @media print{.dontprintme{display:none;}}
    -->
    </style>



    Next, whenever you are serving something that you don't want to be printed,
    place it in a paragraph like this ...
    (this is my print button by the way)
    <p class="dontprintme">
    <BUTTON TYPE=BUTTON onClick="window.print()"
    style="width:250px;height:50px;">&nbsp&nbspPRINT&nbsp&nbsp</BUTTON>
    <p>



    Now, when you run the page, and you click the button, then everything thats
    NOT within a 'dontprintme' paragraph will not be printed.

    HTH,
    PW
    PW, Apr 12, 2008
    #3
  4. tigeressal

    PW Guest

    >
    > First, create a style like this ...
    > <style type="text/css">
    > <!--
    > @media print{.dontprintme{display:none;}}
    > -->
    > </style>
    >
    >
    >
    > Next, whenever you are serving something that you don't want to be
    > printed, place it in a paragraph like this ...
    > (this is my print button by the way)
    > <p class="dontprintme">
    > <BUTTON TYPE=BUTTON onClick="window.print()"
    > style="width:250px;height:50px;">&nbsp&nbspPRINT&nbsp&nbsp</BUTTON>
    > <p>
    >
    >
    >
    > Now, when you run the page, and you click the button, then everything
    > thats NOT within a 'dontprintme' paragraph will not be printed.
    >
    > HTH,
    > PW
    >



    OOPS, that should have said ...
    Now, when you run the page, and you click the button, then everything thats
    NOT within a 'dontprintme' paragraph WILL be printed.
    PW, Apr 12, 2008
    #4
  5. PW wrote:
    > "tigeressal" <> wrote in message
    > news:...
    >> hi,
    >> im new to this group but ill be direct to the point.
    >>
    >> im tryin to create a simple webpage that will print the contents of
    >> the webpage to a printer on a client side machine.
    >>
    >> i know the command is ' window.print() ' and that i can have it in
    >> the ' onload() ' statement so that the print dialouge appears prior to
    >> printing.
    >>
    >> here my question. how do i eliminate the Header and Footer information
    >> that is automatically generated by the webpage?(i.e. the website name
    >> at the top, and the location url at the bottom)
    >>
    >> any help appreciated.
    >>
    >> regards
    >>
    >> rak

    >
    >
    >
    >
    > First, create a style like this ...
    > <style type="text/css">
    > <!--
    > @media print{.dontprintme{display:none;}}
    > -->
    > </style>
    >
    >
    >
    > Next, whenever you are serving something that you don't want to be printed,
    > place it in a paragraph like this ...
    > (this is my print button by the way)
    > <p class="dontprintme">
    > <BUTTON TYPE=BUTTON onClick="window.print()"
    > style="width:250px;height:50px;">&nbsp&nbspPRINT&nbsp&nbsp</BUTTON>
    > <p>


    Ah, but what OP want to excluded is not part of his web page that he
    composed but the URL and date and page numbers that is added by the
    browser by default. This is a user setting on the browser and is not
    controllable by the web author...at least with HTML and CSS


    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Apr 12, 2008
    #5
  6. tigeressal

    tigeressal Guest

    On Apr 12, 3:35 am, "Jonathan N. Little" <> wrote:
    > PW wrote:
    > > "tigeressal" <> wrote in message
    > >news:...


    snipped

    > >> rak

    >
    > > First, create a style like this ...
    > > <style type="text/css">


    snipped

    > > style="width:250px;height:50px;">&nbsp&nbspPRINT&nbsp&nbsp</BUTTON>
    > > <p>

    >
    > Ah, but what OP want to excluded is not part of his web page that he
    > composed but the URL and date and page numbers that is added by the
    > browser by default. This is a user setting on the browser and is not
    > controllable by the web author...at least with HTML and CSS
    >
    > --
    > Take care,
    >
    > Jonathan
    > -------------------


    Hi thanks for the reply, You said its not possible with HTML or CSS.
    Is there a way to do it by other langauges (i.e. specifically PHP)

    Just to let people know, the webpage in question will NOT be on the
    internet but instead on a local nework.
    The printer in question is connected to a client side computer by
    usb.
    AND the end user WILL want to print the page as it will be part of a
    particular process.

    thanks

    rak
    tigeressal, Apr 12, 2008
    #6
  7. tigeressal

    Andy Dingley Guest

    On 12 Apr, 22:12, Ed Jay <> wrote:

    > It is impossible to do via code. It's hard coded into the browser.


    It's not hard-coded into the browser, it's configurable. Some browsers
    may have a programming interface that exposes this, and lets you
    control it. This is likely to be very browser-specific. IE certainly
    does have this, although it requires COM (ad thus ActiveX). If you use
    MeadCo's ScriptX control on your page, it's pretty easy.
    Andy Dingley, Apr 12, 2008
    #7
  8. Andy Dingley wrote:
    > On 12 Apr, 22:12, Ed Jay <> wrote:
    >
    >> It is impossible to do via code. It's hard coded into the browser.

    >
    > It's not hard-coded into the browser, it's configurable. Some browsers
    > may have a programming interface that exposes this, and lets you
    > control it. This is likely to be very browser-specific. IE certainly
    > does have this, although it requires COM (ad thus ActiveX). If you use
    > MeadCo's ScriptX control on your page, it's pretty easy.


    Ol' wild and woolly IE! Same business lets to do all kinds of damage.
    But now with MS's attempt at securing IE won't you get a zillion warning
    dialogs when you invoke such ActiveX? It would hardly be a feasible
    solution. Generate PDF would be the way...some freebee PHP packages out
    there, fpdf comes to mind.

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Apr 12, 2008
    #8
  9. tigeressal

    Andy Dingley Guest

    On 12 Apr, 23:59, "Jonathan N. Little" <> wrote:

    > But now with MS's attempt at securing IE won't you get a zillion warning
    > dialogs when you invoke such ActiveX? It would hardly be a feasible
    > solution.


    No, you can get away with just setting trust up once. As an app that
    _needs_ to control print sizes is probably something that the user has
    a non-trivial relationship with, this might be enough.
    Andy Dingley, Apr 13, 2008
    #9
  10. On Apr 12, 5:12 pm, Ed Jay <> wrote:
    > It is impossible to do via code...


    Ed, are your comment so unimportant that you don't think anyone will
    want to read them after a week, or are you just selfish?
    Travis Newbury, Apr 13, 2008
    #10
  11. Ed Jay wrote:
    > Travis Newbury scribed:
    >
    >> On Apr 12, 5:12 pm, Ed Jay <> wrote:
    >>> It is impossible to do via code...

    >> Ed, are your comment so unimportant that you don't think anyone will
    >> want to read them after a week, or are you just selfish?

    >
    > What are you talking about?


    Obscure? Yep! But this is what he was referring to:

    X-No-Archive: yes

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Apr 13, 2008
    #11
  12. Neredbojias wrote:
    > On 13 Apr 2008, Ed Jay <> wrote:
    >
    >> Travis Newbury scribed:

    >
    >>> Ed, are your comment so unimportant that you don't think anyone will
    >>> want to read them after a week, or are you just selfish?

    >> What are you talking about?

    >
    > Well, his name is Jonathan "Little" so maybe he's just making "small"
    > talk.
    >


    Hey, it wasn't me being the protocol-nazi I was just explaining what
    Travis meant by is remark.

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Apr 13, 2008
    #12
  13. Ed Jay wrote:

    > Two answers to the questions. I am selfish, and I don't know why No
    > X-archive was checked. This post should be archived forever; however, most
    > of my posts have already found their place in the anals of history. ;-)


    Nope, your X-No-Archive is still set.

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Apr 13, 2008
    #13
  14. On Apr 13, 7:53 pm, Neredbojias <me@http://www.neredbojias.com/_eml/
    fliam.php> wrote:
    > Actually, I think his brain may have become
    > addled by perusing so much Flash. That don't make him a bad guy...


    Or does it.....
    Travis Newbury, Apr 14, 2008
    #14
  15. tigeressal wrote:

    > Just to let people know, the webpage in question will NOT be on the
    > internet but instead on a local nework. The printer in question is
    > connected to a client side computer by usb.


    If it's part of an app running on a LAN, then the solution might be to
    print from the *server* not the client. That way, you ought to be able to
    control the printing perfectly. (The printer can still be physically
    attached the the client computer -- the server could access via CUPS or
    Windows printer sharing.)

    --
    Toby A Inkster BSc (Hons) ARCS
    [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
    [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 7 days, 14:09.]

    Dr Who Goes To Pompeii
    http://tobyinkster.co.uk/blog/2008/04/13/dr-who-pompeii/
    Toby A Inkster, Apr 29, 2008
    #15
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sam
    Replies:
    1
    Views:
    653
    seigo
    Nov 10, 2006
  2. keto
    Replies:
    0
    Views:
    927
  3. David Cournapeau

    print a vs print '%s' % a vs print '%f' a

    David Cournapeau, Dec 30, 2008, in forum: Python
    Replies:
    0
    Views:
    347
    David Cournapeau
    Dec 30, 2008
  4. prakash
    Replies:
    2
    Views:
    586
    prakash
    Apr 11, 2005
  5. Javascript Print Command

    , Feb 17, 2006, in forum: Javascript
    Replies:
    2
    Views:
    95
Loading...

Share This Page