SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot virginiamonkeys's Avatar
    Join Date
    Jun 2003
    Location
    Stafford, Virginia, USA
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to make javascript disappear for printer

    I have a troublesome script on a site I'm designing. The site is in test mode at http://www.monkeywithatypewriter.com...nos2/index.htm. If you go to print the page, you will get the menu right in the middle of the main text.

    The javascripts are located at http://www.monkeywithatypewriter.com...mplmenu_var.js and the rest of it is at http://www.monkeywithatypewriter.com...ts/menu_com.js.

    How can I get the menu to position itself properly during a print, or at least disappear during a print?

    Thanks.

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Give your menu an ID of "menu" and you can use this CSS code:
    Code:
    <style type="text/css" media="print">
      #menu {
          display: none;
      }
    </style>
    This way, your menu will still show up on screen, but the printer won't print it.

  3. #3
    SitePoint Zealot virginiamonkeys's Avatar
    Join Date
    Jun 2003
    Location
    Stafford, Virginia, USA
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope. I tried that with CSS yesterday. I spent 8 hours trying to get that to work. Couldn't get it. I was hoping there was a different answer to that one.

    Now, if you can get that idea to work, I guess you're better at this than I am.

  4. #4
    SitePoint Zealot virginiamonkeys's Avatar
    Join Date
    Jun 2003
    Location
    Stafford, Virginia, USA
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Am I correct in assuming that this one isn't going to be fixed?

  5. #5
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've tried placing it in a div that should be hidden for screen media as well and yet the menu still appears on screen. It even ignores it when the body selector itself is given the display: none; attribute (css).
    The problem appears to be that the javascript document.write() is completely ignoring the display/visibility settings of its parent element.

    I imagine this is because the browser is treating the javascript menu code almost as an unrelated stream of code.

    Have you tried using php to include the javascript menu code directly in every page?
    This may not be the most graceful option, but it might enable it to work.

    Even if you were unwilling to consider it as a full-time workaround, it might still be worth embedding the (huge) javascript menu code directly into a page and then seeing how that page prints. That way the browser might be more inclined to treat the page as a whole and may correctly display the menu (or rather- not).
    If nothing else it might help you to get to the root of the problem.

    Just an idea.
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature


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
  •