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

    disable javascript using css

    Hello all!

    I'm designing a printer friendly page using the css @media type. I have also in that page a javascript menu that needs to be disabled to get a printer friendly page. How can I disable javascript using css?

    Thnx!

  • #2
    Regular Coder
    Join Date
    May 2004
    Location
    Berkeley, California Age: 15
    Posts
    398
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, you can't disable javascript with css..But you can get rid of the result of javascript...

    You can just use display: none or visibility: hidden on the javascript generated elements, and you should be on your way.
    Jalenack.com .:. YWDA Founder .:. Rounded Corners Maker 1.1! .:. My Blog
    The hardest thing about teaching is not knowing the right answers, but knowing the right questions - Elisabeth Klein
    Pretty buttons does not a great website make.

  • #3
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I already tried that, my code looks something like this:

    In the head section:

    <style>
    @media print {.noprint {display: none; visibility: hidden;}}
    </style>

    And in the body:

    <p class="noprint">
    <script language="JavaScript" src="menu.js"></script>
    </p>

    But it still renders the menu when printing...

  • #4
    Senior Coder
    Join Date
    Jul 2005
    Location
    UK
    Posts
    1,051
    Thanks
    6
    Thanked 13 Times in 13 Posts
    Surely -

    <style>
    .noprint {display: none; visibility: hidden;}
    </style>

    <p class="noprint">
    <script language="JavaScript" src="menu.js"></script>
    </p>

    Is what you are looking for?

  • #5
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, I guess not...
    removing the '@media print' from the style, makes the page render printer friendly on screen also...and still with menu!

  • #6
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ah, finally figured it out!

    I replaced <p class="noprint"> with <div class="noprint">
    Don't know why the paragraph option doesn't work, but what the hell...the div does the job.

    Thnx all!


  •  

    Posting Permissions

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