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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    remove elements in web page before printing

    Hello,

    I am French. sorry if my english is bad.

    I have a problem. I want remove somethink in web page befor printing. I found some exemple but it work with IE7 but it don't work with Firefox.

    <!-- DEBUT REMOVE PRINT-->
    <!--http://www.javascriptkit.com/-->
    <script language="JavaScript">
    function removeelements(){
    //store all elements with id=remove to "remove_el"
    var remove_el=document.write.remove
    var remove_el=document.all.remove
    //if there is only one element with id=remove
    if (remove_el!=''&&remove_el.length==null)
    remove_el.style.display='none'
    else{
    //for each element with id=remove
    for (i=0;i<remove_el.length;i++)
    remove_el[i].style.display='none'
    }
    }
    function revertback(){
    setTimeout("window.location.reload()",50)
    }
    window.onbeforeprint=removeelements
    window.onafterprint=revertback
    </script>
    <!-- FIN REMOVE PRINT-->


    I know that "window.onbeforeprint" is not supported by firefox. it work well with IE7. I put id=remore in each balise



    I have a second solution but I don't know how it don't work

    <link href="afpca.css" rel="stylesheet" type="text/css" />
    <link href="imprimante.css" rel="stylesheet" type="text/css" media="print" />


    in file imprimante.css i write :
    #remove {
    display: none;
    }


    my print button ;
    <input name="Imprimez" onclick="window.print()" class="formbutton" id="Imprimez" value="Imprimez" type="button" />

    It don't do anythink . grrr !! but if I use "imprimante.css" with using google developpers toolbar it's ok.

    Please , what I miss in my web page

    Thank you very much for answers.

    Amalpartout

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    The Netherlands, Baarn, Ut.
    Posts
    4,252
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Print styles

    You're definitely on the right track; a print stylesheet can be used to suppress certain elements you don't want to print.
    However, the style rule in your print style sheet (imprimante.css) says:

    "set all elements with id="remove" to not displaying". I see no id="remove" in your button... Either add the id, or change the selector in the rule.

    also, you may need to set a specific media type on the default style sheet (afpca.css) as well.

    More information on print stylesheets can be found in Eric Meyer's article " CSS Design: Going to Print" on ALA.
    Regards,
    Ronald.
    ronaldvanderwijden.com

  • #3
    New to the CF scene
    Join Date
    Jul 2007
    Location
    Wales
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Why don't you just make a Printer Friendly Version page and use a print button?


  •  

    Posting Permissions

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