SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Feb 2004
    Location
    somewhere
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hide layer on print (not a css problem)

    I'm using some js to hide and show layers and a separately defined stylesheet for printing showing all the layers as paragraphs but when you go to print the page, if you aren't currently on the default layer, the layer you are currently on overlaps the #print div even though that layer is defined as hidden in the css.

    Exteternal js:

    var isDHTML = 0;
    var isLayers = 0;
    var isAll = 0;
    var isID = 0;

    if (document.getElementById) {isID = 1; isDHTML = 1;}
    else {
    browserVersion = parseInt(navigator.appVersion);
    if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {isLayers = 1; isDHTML = 1;}
    else {
    if (document.all) {isAll = 1; isDHTML = 1;}
    }}

    function findDOM(objectID,withStyle) {
    var menuArea = "menuArea";
    if (withStyle == 1) {
    if (isID) { return (document.getElementById(objectID).style) ; }
    else {
    if (isAll) { return (document.all[objectID].style); }
    else {
    if (isLayers) { return (document.layers[menuArea].layers[objectID]); }
    };}
    }
    else {
    if (isID) { return (document.getElementById(objectID)) ; }
    else {
    if (isAll) { return (document.all[objectID]); }
    else {
    if (isLayers) { return (document.layers[menuArea].layers[objectID]); }
    };}
    }
    }

    JS in the html:

    <script src="findDOM.js" type="text/javascript"></script>
    <script language="JavaScript" type="text/javascript">
    if (isLayers)
    document.write('<link href="pop-style.css" media="screen"

    rel="styleSheet" type="text/css"><link href="pop-print.css" media="print" rel="styleSheet" type="text/css">');
    else
    document.write('<link href="pop-style.css" media="screen"

    rel="styleSheet" type="text/css"><link href="pop-print.css" media="print" rel="styleSheet" type="text/css">');
    </script>

    <script language="JavaScript" type="text/javascript"><!--
    var objectIDCurr = 'ch2';

    function setVisibility(objectID) {
    var domNew = findDOM(objectID,1);
    var domCurr = findDOM(objectIDCurr,1);
    domCurr.visibility = "hidden";
    domNew.visibility = "visible";
    objectIDCurr = objectID;
    }

    // -->
    </script>

    How can I force it to hide everything but the print layer when you go print it out?

    Thanks!!!

    Barrie

  2. #2
    SitePoint Member
    Join Date
    Mar 2004
    Location
    Belgrade
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here U can find nice printing tutorial:
    http://www.faqts.com/knowledge_base/...html/aid/14803

  3. #3
    SitePoint Member
    Join Date
    Feb 2004
    Location
    somewhere
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks dzonileon!

    That doesn't quite do what I was looking for but it gave me information which made me decide I was better off using an alternate, printer-friendly page instead

    I've already made the changes to the affected pages, but in the event I ever want to do something like this again, does anyone have an answer to how to change the above code so that the current layer as defined by the JS would be hidden on print?

    Thanks!!!

    b


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
  •