Results 1 to 8 of 8

Thread: No Printing with 100% CSS layout

  1. #1
    Join Date
    Aug 2007
    Location
    Ft Myers, FL
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default No Printing with 100% CSS layout

    I have a webpage that contains an activeX that displays a medical chart

    What would be the best way to stop these 2 divs from being printable?

    Code:
    <div class="container">
        <div class="AddendumForm" id="AddendumForm">
        </div>
        <div class="Chart" id="Chart">  
        </div>
    </div>

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    why are you using a class and an id for each of those elements? if the element occurs once use the id, if it occurs multiple times on that page use the class.

    you mean when someone goes to print those 2 do not go with it?
    you can create a print style sheet.

    print.css
    Code:
    div#AddendumForm {display:none;}
    div#Chart {display:none;}
    use the pound key (#) if you use id
    use the dot key (.) if yo uuse class

    then in the header script you can do something like
    Code:
    ...DOCTYPE (HTML 4.01 STRICT)...
    <head>
         <link type="text/css" rel="stylesheet" href="screen.css" media="screen">
         <link type="text/css" rel="stylesheet" href="print.css" media="print">
    </head>
    dark orange are the file names you need to match up to yours
    blue is the media type you wish to apply that stylesheet to

  3. #3
    Join Date
    Aug 2007
    Location
    Ft Myers, FL
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I had originally just used the class, but I added some JS to the page and it needed the ID.

  4. #4
    Join Date
    Aug 2007
    Location
    Ft Myers, FL
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    And i have style sheet in the head tag
    Code:
    <head>
    <style type="text/css">
        FORM        { FONT-FAMILY: Arial, Helvetica, sans-serif; FONT-SIZE: 12px }
        INPUT        { FONT-FAMILY: Arial, Helvetica, sans-serif; FONT-SIZE: 12px }
        SELECT        { FONT-FAMILY: Arial, Helvetica, sans-serif; FONT-SIZE: 12px }
        TEXTAREA    { FONT-FAMILY: Arial, Helvetica, sans-serif; FONT-SIZE: 12px }
        TABLE        { FONT-FAMILY: Arial, Helvetica, sans-serif; FONT-SIZE: 12px }
        TR        { FONT-FAMILY: Arial, Helvetica, sans-serif; FONT-SIZE: 12px }
        TD        { FONT-FAMILY: Arial, Helvetica, sans-serif; FONT-SIZE: 12px }
    
    
    </style>
    </head>

  5. #5
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Quote Originally Posted by fmrock View Post
    I had originally just used the class, but I added some JS to the page and it needed the ID.
    you can use getElementByClass('class') in your javascript.
    you really should follow conventions though on which method you use. id or class.
    Quote Originally Posted by fmrock View Post
    And i have style sheet in the head tag
    Code:
    <head>
    <style type="text/css">
        FORM        { FONT-FAMILY: Arial, Helvetica, sans-serif; FONT-SIZE: 12px }
        INPUT        { FONT-FAMILY: Arial, Helvetica, sans-serif; FONT-SIZE: 12px }
        SELECT        { FONT-FAMILY: Arial, Helvetica, sans-serif; FONT-SIZE: 12px }
        TEXTAREA    { FONT-FAMILY: Arial, Helvetica, sans-serif; FONT-SIZE: 12px }
        TABLE        { FONT-FAMILY: Arial, Helvetica, sans-serif; FONT-SIZE: 12px }
        TR        { FONT-FAMILY: Arial, Helvetica, sans-serif; FONT-SIZE: 12px }
        TD        { FONT-FAMILY: Arial, Helvetica, sans-serif; FONT-SIZE: 12px }
    
    
    </style>
    </head>
    why not combine these into
    Code:
    <style type="text/css">
    body {
         font-family: Arial, Helvetica, sans-serif;
         font-size: 12px;
    }
    </style>
    those styles are for general use, and you are not explicitly declaring a display property of any of those selectors, thus you can still use the print style sheet to get rid of the wanted element(s). especially since the elements you wanted to get rid of.. was a div, which is none of those.


    however if you do not want to use a linked style sheet, you can create a new css style declaration and use media in there
    Code:
    <style type="text/css" media="print">
    div(. or #)selector {
         display:none
    }
    </style>
    and it will work the same way

    just be sure to use the appropriate selector name, and also use dot/pound for whatever you decide to use in the end

  6. #6
    Join Date
    Aug 2007
    Location
    Ft Myers, FL
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for all the help.. I will adjust my JS and fix up my style sheet which that was only a small portion of.

    The printing seems to be mostly working, but the activeX control is still printing, but nothing else is.

    Would i need to do something special to that activeX which is in the Chart Div?

  7. #7
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    you never said anything about javascript in your initial post..
    can you please post your site url so we can troubleshoot it more thoroughly, and read http://www.dynamicdrive.com/forums/s...ad.php?t=24866

  8. #8
    Join Date
    Aug 2007
    Location
    Ft Myers, FL
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Even thought the object was in the chart div, it was still printing.

    So i just added object to the CSS.

    Code:
    <style type="text/css" media="print">
    div#container {
         display:none
    }
    
    div#AddendumForm {
         display:none
    }
    
    div#Chart {
         display:none
    }
    
    object{
    	display:none;
    }
    </style>

Bookmarks

Posting Permissions

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