Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

Turning Javascript off while printing

Question posted by: Jlcarroll (Guest) on July 23rd, 2007 01:45 AM
Hi,

I am building a web page.and have a simple javascript menu... I call
the javascript menu within a div block that my print sytlesheet has
set as a display: none;, well all the content in that block doesn't
show up, EXCEPT the javascript is still getting run...


<div class="menu">
<!--*****************These lines load in the
menu.***************************-->

<div id='MenuPos' style='position:relative; width:120; height:201;
margin-left:10px'>

<script type='text/javascript'>

//HV Menu v5- by Ger Versluis (http://www.burmees.nl/)

//Submitted to Dynamic Drive (http://www.dynamicdrive.com)

//Visit http://www.dynamicdrive.com for this script and more



function Go(){return}



</script>

<script type='text/javascript' src='/includes/jlc_menu.js'></script>

<script type='text/javascript' src='/includes/menu_com.js'></script>

<noscript>Your browser does not support script</noscript>
</div>

the stuff that doesn't show up when printing, just as it should....
<!-- *End menu*-->
</div>

Any idea how to fix this?

Thanks a bunch!

Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
David Mark's Avatar
David Mark
Guest
n/a Posts
July 23rd, 2007
01:55 AM
#2

Re: Turning Javascript off while printing
On Jul 22, 9:35 pm, Jlcarroll <jlcarr...@gmail.comwrote:
Quote:
Originally Posted by
Hi,
>
I am building a web page.and have a simple javascript menu... I call
the javascript menu within a div block that my print sytlesheet has
set as a display: none;, well all the content in that block doesn't
show up, EXCEPT the javascript is still getting run...
>
<div class="menu">
<!--*****************These lines load in the
menu.***************************-->
>
<div id='MenuPos' style='position:relative; width:120; height:201;
margin-left:10px'>
>
<script type='text/javascript'>
>
//HV Menu v5- by Ger Versluis (http://www.burmees.nl/)
>
//Submitted to Dynamic Drive (http://www.dynamicdrive.com)


Oh no.
Quote:
Originally Posted by
>
//Visithttp://www.dynamicdrive.comfor this script and more
>


For the love of God, don't.
Quote:
Originally Posted by
function Go(){return}
>
</script>
>
<script type='text/javascript' src='/includes/jlc_menu.js'></script>
>
<script type='text/javascript' src='/includes/menu_com.js'></script>
>
<noscript>Your browser does not support script</noscript>


Delete this. It serves no purpose. Better yet, write your menu
without script and then look for a non-invasive menu script.
Quote:
Originally Posted by
</div>
>
the stuff that doesn't show up when printing, just as it should....
<!-- *End menu*-->
</div>
>
Any idea how to fix this?


The script is going to run regardless of the page's style. What's the
problem (besides the lousy script?) Is it making the menu show up
when the page loads?


Jlcarroll's Avatar
Jlcarroll
Guest
n/a Posts
July 23rd, 2007
02:25 AM
#3

Re: Turning Javascript off while printing
oh, I guess that I wasn't clear... I want the script to run on the
screen display, but I want the print display to leave the menu off...
everything in the div block isn't displayed on print, EXCEPT this
bloody menu.

As for a "non-invasive" script... I did this YEARS ago, back before
css even existed... back then I was using tables to do the layout...
ugg ya..., and just finally got around to upgrading to css. But I
haven't gotten around to changing the menu script used... it has
worked fine for me until now. Although I am good at html, I must admit
that I don't know javascript at all, so I don't know what you mean by
invasive or non invasive scripts. Nor do I know how using a different
menu script would help me get it to not run when I am printing the
page.

I am sure that I am doing many things wrong, but I appreciate help
learning to do this right...

Thanks for your help,

James

On Jul 22, 7:48 pm, David Mark <dmark.cins...@gmail.comwrote:
Quote:
Originally Posted by
On Jul 22, 9:35 pm, Jlcarroll <jlcarr...@gmail.comwrote:
>
>
>
Quote:
Originally Posted by
Hi,

>
Quote:
Originally Posted by
I am building a web page.and have a simple javascript menu... I call
the javascript menu within a div block that my print sytlesheet has
set as a display: none;, well all the content in that block doesn't
show up, EXCEPT the javascript is still getting run...

>
Quote:
Originally Posted by
<div class="menu">
<!--*****************These lines load in the
menu.***************************-->

>
Quote:
Originally Posted by
<div id='MenuPos' style='position:relative; width:120; height:201;
margin-left:10px'>

>
Quote:
Originally Posted by
<script type='text/javascript'>

>
Quote:
Originally Posted by
//HV Menu v5- by Ger Versluis (http://www.burmees.nl/)

>
Quote:
Originally Posted by
//Submitted to Dynamic Drive (http://www.dynamicdrive.com)

>
Oh no.
>
>
>
Quote:
Originally Posted by
//Visithttp://www.dynamicdrive.comforthis script and more

>
For the love of God, don't.
>
Quote:
Originally Posted by
function Go(){return}

>
Quote:
Originally Posted by
</script>

>
Quote:
Originally Posted by
<script type='text/javascript' src='/includes/jlc_menu.js'></script>

>
Quote:
Originally Posted by
<script type='text/javascript' src='/includes/menu_com.js'></script>

>
Quote:
Originally Posted by
<noscript>Your browser does not support script</noscript>

>
Delete this. It serves no purpose. Better yet, write your menu
without script and then look for a non-invasive menu script.
>
Quote:
Originally Posted by
</div>

>
Quote:
Originally Posted by
the stuff that doesn't show up when printing, just as it should....
<!-- *End menu*-->
</div>

>
Quote:
Originally Posted by
Any idea how to fix this?

>
The script is going to run regardless of the page's style. What's the
problem (besides the lousy script?) Is it making the menu show up
when the page loads?




rbevers@eprod.com's Avatar
rbevers@eprod.com
Guest
n/a Posts
July 26th, 2007
06:05 PM
#4

Re: Turning Javascript off while printing
On Jul 22, 7:35 pm, Jlcarroll <jlcarr...@gmail.comwrote:
Quote:
Originally Posted by
Hi,
>
I am building a web page.and have a simple javascript menu... I call
the javascript menu within a div block that my print sytlesheet has
set as a display: none;, well all the content in that block doesn't
show up, EXCEPT the javascript is still getting run...
>
<div class="menu">
<!--*****************These lines load in the
menu.***************************-->
>
<div id='MenuPos' style='position:relative; width:120; height:201;
margin-left:10px'>
>
<script type='text/javascript'>
>
//HV Menu v5- by Ger Versluis (http://www.burmees.nl/)
>
//Submitted to Dynamic Drive (http://www.dynamicdrive.com)
>
//Visithttp://www.dynamicdrive.comfor this script and more
>
function Go(){return}
>
</script>
>
<script type='text/javascript' src='/includes/jlc_menu.js'></script>
>
<script type='text/javascript' src='/includes/menu_com.js'></script>
>
<noscript>Your browser does not support script</noscript>
</div>
>
the stuff that doesn't show up when printing, just as it should....
<!-- *End menu*-->
</div>
>
Any idea how to fix this?
>
Thanks a bunch!



The best way to do it is with css. Like this:

<style type="text/css" media=print>
..menuBar{display:none;}
</style>

<style type="text/css">
..menuBar{font-family:Arial;
//all of the rest of the style for your menuBar}
</style>

when you declare the first div for your menu <div class=menuBar>

When sent to the printer, it will see the media is "print" and make
the menu invisable

I hope this helps. I do it on all of my web sites



 
Not the answer you were looking for? Post your question . . .
182,322 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors