...

View Full Version : disable javascript using css



Beek
07-18-2005, 10:40 AM
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!

Jalenack
07-18-2005, 11:33 AM
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.

Beek
07-18-2005, 11:52 AM
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... :confused:

Pennimus
07-18-2005, 12:03 PM
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?

Beek
07-18-2005, 12:10 PM
Well, I guess not...
removing the '@media print' from the style, makes the page render printer friendly on screen also...and still with menu! :(

Beek
07-18-2005, 03:44 PM
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. :D

Thnx all!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum