Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    362
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hiding Print button on the printed hardcopy

    Anyway to hide a button such as a "Print" button when the page has been printed to hardcopy? I have a Print button on my HTML page for printing but I dont want the Print button to show up on the printed hardcopy output.

    Please advise how I can do this with what I have below:


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

    <form>
    <input type="button" value="Print" onClick="myprintfunction();">
    </form>

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    1,137
    Thanks
    0
    Thanked 0 Times in 0 Posts
    in one browser you can use the onprint function or method.

    scroots
    Spammers next time you spam me consider the implications:
    (1) that you will be persuaded by me(in a legitimate mannor)
    (2)It is worthless to you, when i have finished

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Oakville
    Posts
    160
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <script>

    ns4 = (document.layers)? true:false;
    ie4 = (document.all)? true:false;
    function myprintfunction(id) {
    if (ns4) document.layers[id].visibility = "hide"
    else if (ie4) document.all[id].style.visibility = "hidden"
    window.print();
    }
    </script>


    <DIV ID="xxx" STYLE="position:relative;">

    <input type="button" value="Print" onClick="myprintfunction('xxx');">

    </DIV>

    Try putting the button in a layer then hide the layer? Might work.

    Steven

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can use CSS for this
    Code:
    <style type="text/css">
    @media print {
        input#printButton {
            display: none;
            }
        }
    </style>
    
    <input type="button" id="printButton" onclick="window.print();" value="Print Page" />
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #5
    Regular Coder
    Join Date
    Jul 2002
    Posts
    362
    Thanks
    0
    Thanked 0 Times in 0 Posts
    These all work in IE but the button still shows up in my Netscape 4 browser printout.

    Please advise

  • #6
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Don't expect to get NS4 to do a lot of what you want it to.

    It is 5 years old, after all.
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #7
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,065
    Thanks
    4
    Thanked 8 Times in 8 Posts
    what if you want to hide an image on the same page? I use the css code to hide the print button but there are two image files i wanted to hide. wgat I did was added a class called images and an id called images to each img tag and then added this class to the stylesheet to hide but to no avail. Any ideas what i did wrong?

    <style type="text/css">
    @media print {
    input#print {
    display: none;
    }
    img#images {
    display: none;
    }
    }
    </style>

  • #8
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You used an ID selected when you need a class selector.

    img.images {
    display: none;
    }

    The # denotes an ID selector, the . denotes a class selector
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”


  •  

    Posting Permissions

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