apply a print-only style

Discussion in 'Javascript' started by Andrew Poulos, Jul 10, 2009.

  1. I can do something like

    document.getElementById("btn").style.visibility = "hidden";

    but is there a way to apply a style so that it only applies when the
    page is being printed? I don't mean applying a style only while the page
    is being printed and then removing the style when the page has finished
    printing but, rather, the equivalent of

    <style type="text/css" media="print">
    #btn { visibility: hidden; }
    </style>

    Andrew Poulos
     
    Andrew Poulos, Jul 10, 2009
    #1
    1. Advertising

  2. Andrew Poulos wrote:
    > I can do something like
    >
    > document.getElementById("btn").style.visibility = "hidden";
    >
    > but is there a way to apply a style so that it only applies when the
    > page is being printed? I don't mean applying a style only while the page
    > is being printed and then removing the style when the page has finished
    > printing but, rather, the equivalent of
    >
    > <style type="text/css" media="print">
    > #btn { visibility: hidden; }
    > </style>


    Its ok, I just discovered I can do

    @media print {
    #btn {
    visibility: hidden:
    }
    }

    in the style sheet. I'm not in a position to add to the head of the page
    in question but I could edit the javascript or the CSS it referenced.

    Andrew Poulos
     
    Andrew Poulos, Jul 10, 2009
    #2
    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. Shiperton Henethe
    Replies:
    5
    Views:
    1,156
    Adrienne
    Sep 19, 2003
  2. Stefan Siegl
    Replies:
    1
    Views:
    986
    Marrow
    Jul 18, 2003
  3. keto
    Replies:
    0
    Views:
    1,023
  4. David Cournapeau

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

    David Cournapeau, Dec 30, 2008, in forum: Python
    Replies:
    0
    Views:
    389
    David Cournapeau
    Dec 30, 2008
  5. Ken Varn
    Replies:
    0
    Views:
    506
    Ken Varn
    Apr 26, 2004
Loading...

Share This Page