Functions to hide menu while printing no longer work

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
Marc-Andre.Roberge@mus.ul
Super Advanced
Super Advanced
Posts: 47
Joined: Sun May 19, 2002 7:23 pm
Location: Québec, QC, Canada
Contact:

Functions to hide menu while printing no longer work

Post by Marc-Andre.Roberge@mus.ul »

Back in the time of version 3, Andy or someone who is very knowledgeable suggested using the following code to cause the menu to disappear briefly while the print command is issued in order to prevent printing problems. I thus inserted the following code in the page:

Code: Select all

</script>
<script type="text/javascript" language="JavaScript"><!-- 
function hide_menu(mnu){ 
mn=getMenuByName(mnu) 
SDiv("menu"+mn,0) 
} 

function show_menu(mnu){ 
mn=getMenuByName(mnu) 
SDiv("menu"+mn,1) 
} 
//--></script>
The page also includes a "Easy printing" link:

Code: Select all

<a href='javascript:hide_menu("mainmenu");self.print();show_menu("mainmenu")'>Impression facile</a>
Now, with version 5 (RC28), clicking on the link does absolutely nothing and returns the message "Error on the page". Does this happen because the "mainmenu" parameter passed to the functions is no longer valid? If so, what should it be?

I may also simply decide to delete the functions because the printing problem I had at the time seems to have disappeared. In fact, issuing the printing command in IE6 (PC) caused this application to generate a temporary printing file containing all the contents of my menu and submenus to be included, and this locked my HP LaserJet 2200d.

One printing problem remains, however, when printing pages using the Milonic menu, it happens that the last line of text is truncated vertically, i.e., the top part appears at the bottom of the page, and the rest goes at the top of the next page. I have seen this elsewhere once in a while, but is there a way to prevent this from happening?
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

You could try replacing your show_menu() and hide_menu() function definitions with the following:

Code: Select all

function show_menu(menuName)
{
  popup(menuName);
}

function hide_menu(menuName)
{
  menuDisplay(getMenuByName(menuName), 0);
} 
Your "Easy Printing" links should then work as they did in the past, assuming that your main menu is still named "mainmenu".

Another option: since Milonic menus now let you apply css styles directly, you could (in theory) use Media Type definitions to prevent the menu from printing. This would have the advantage of letting the user print from a link or using the browser's native print function. Disadvantage would be that it won't work in older browsers that don't support media types. I haven't actually tried this myself, but as I said, it should work.

Kevin
Marc-Andre.Roberge@mus.ul
Super Advanced
Super Advanced
Posts: 47
Joined: Sun May 19, 2002 7:23 pm
Location: Québec, QC, Canada
Contact:

Post by Marc-Andre.Roberge@mus.ul »

I was quite discouraged to see that my message was eliciting no response at all. Thanks for yours, which I will investigate as soon as I can.
Post Reply