Back To Start Of Archive
Taken From The Forum: Archived Topics for the old Version 3.0 JavaScript Menu
Forum Topic: Click to view post
Last Updated: Wednesday July 18 2012 - 06:07:41
Hide the entire Menu
Poster: paulm __at__ mit-comms.co.uk
Dated: Monday April 29 2002 - 13:42:55 BST
OK,
still trying to hide the menu when I click on the print Icon.......
Any idea why this does not work?
,"<img src=images/buttons/print2.gif border=0>
Re: Hide the entire Menu
Poster: Andy
Dated: Monday April 29 2002 - 13:51:07 BST
Hi,
You are not far off.
getMenuByName() returns the menu number not the object reference.
To get a reference to the menu you need to use gmobj()
Try this.
spos(gmobj("menu" getMenuByName("mainmenu")),-100,0,0)
I've tested it and it works.
Cheers
Andy
Re: Hide the entire Menu
Poster: paulm __at__ mit-comms.co.uk
Dated: Monday April 29 2002 - 15:22:54 BST
Ok, got this working *sweeeeeet*
Put this is the Addmenu list..... (this option is in a submenu called 'output')
,"<img src=images/buttons/print2.gif border=0>
Hiding Menu
Poster: nev
Dated: Thursday August 15 2002 - 21:45:38 BST
Do you mean that you can hide the menu when you print the page from within IE. I would be interest to learn how to do this if this is what you meant.
Having problems positioning the menu when printing. Hiding it will solve the problem
Thanks
Nev
Poster: Andy
Dated: Thursday August 15 2002 - 22:43:55 BST
You can Show and Hide menus with this custom function.
This Hides a menu by it's name
Code:
function hide_menu(mnu){
mn=getMenuByName(mnu)
SDiv("menu"+mn,0)
}
hide_menu("mainmenu")
mn=getMenuByName(mnu)
SDiv("menu"+mn,0)
}
hide_menu("mainmenu")
This displays a menu by it's name
Code:
function show_menu(mnu){
mn=getMenuByName(mnu)
SDiv("menu"+mn,1)
}
show_menu("mainmenu")
mn=getMenuByName(mnu)
SDiv("menu"+mn,1)
}
show_menu("mainmenu")
Hope this helps
Andy
Re: Hide the entire Menu
Poster: pstarkey __at__ cinergy.com
Dated: Tuesday February 4 2003 - 20:43:10 GMT
Not sure how to use the function Andy showed. I use a stylesheet with a media section to hide things on pages when I print. But I can't use it with the menu.
I do not understand paulm's suggestion either - I cannot figure out where to place the option and what is your print2.gif actually? just a 1pixel x 1pixel gif effectively making it a picture of nothing?
I just want to hide the entire menu when printing.
Thanks for any help you can offer!
Poster: kevin3442
Dated: Tuesday February 4 2003 - 23:45:08 GMT
Hi,
I would assume that the functions Andy provided are meant to be incorporated into a third printing function that you provide.
Quote:
I do not understand paulm's suggestion either - I cannot figure out where to place the option and what is your print2.gif actually? just a 1pixel x 1pixel gif effectively making it a picture of nothing?
It looks to me like paulm's intent was to provide a print option as one of the menu items in a larger menu. But the given example was cut off part way through; it only shows the first of five fields for a menu item definition. The .gif image was probably not a transparent gif, but rather was simply an image at the beginning of the menu item used to print the page (either that, or it was the only thing in the menu item's "Description" field, in an image-only menu). Anyway, the menu item definition might look something like this (no images used here):
Code:
,"Print this page","javascript:print_page()",,,1
The javascript code to support this menu item, incorporating Andy's functions, might look like this:
Code:
function hide_menu(mnu){
mn=getMenuByName(mnu)
SDiv("menu"+mn,0)
}
function show_menu(mnu){
mn=getMenuByName(mnu)
SDiv("menu"+mn,1)
}
function print_page()
hide_menu("mainmenu"); // substitute the name of your main menu
if (window.print) window.print();
show_menu("mainmenu"); // substitute the name of your main menu
}
mn=getMenuByName(mnu)
SDiv("menu"+mn,0)
}
function show_menu(mnu){
mn=getMenuByName(mnu)
SDiv("menu"+mn,1)
}
function print_page()
hide_menu("mainmenu"); // substitute the name of your main menu
if (window.print) window.print();
show_menu("mainmenu"); // substitute the name of your main menu
}
You might put this code at the top of your menu_array.js file, at the beginning of the "editable properties".
This is meant only to illustrate what I believe was the original idea of this thread. As it stands above, the print_page() function hides the main menu, calls the window.print method, then reshows the main menu. It may not work completely for your unique purpose... you'd want to add to the approach (perhaps in the print_page() function) anything that you normally do to prepare for printing.
Hope that helps,
Kevin
Hide the entire Menu
Poster: pstarkey __at__ cinergy.com
Dated: Thursday February 6 2003 - 14:30:44 GMT
Success!! Using the menu_hide and menu_show, I used the DOM window_onbeforeprint and window_onafterprint events to call the menu hide and show functions.
In the window_onbeforeprint, I called the menu_hide function and hid the main menu and in the window_onafterprint, I called the menu_show function and unhid the menu.
The nice thing about this (other than the fact that it hides the menu during print), is that the two events happen VERY fast and the menu never really disappears on the screen.