|
How can I hide my css navigation bar when I print my page?
Return to Recent Questions
Q:
Can I use javascript to get the object ID (getElementByID). If not how
do I hide my css navigation bar when I print the page?
A:
You can add a new button to print your page and call onClick event, so
you should write:
<body ....
onClick="document.getElementById('dm0m0').style.visibility='hidden'; window.print();">
...
</body>
Or you can use the same javascript code from your menu item.
For example:
var menuItems = [
["Print", "javascript:document.getElementById('dm0m0').style.visibility='hidden';
window.print();", icon1, icon2],
];
But if you want to hide the css navigation bar when your customers push "File/Print"
you should write so:
Create two functions, for example:
function myprint()
{ document.getElementById('dm0m0').style.visibility='hidden';
window.print();
}
function myprint2()
{ document.getElementById('dm0m0').style.visibility='visible';
window.print();
}
You should add this functions into your code.
And then you must write the following code:
window.onbeforeprint = myprint;
window.onafterprint = myprint2;
Return to Recent Questions
Related:
- March 16, 2009 - Is there any way to keep a menu using css lit up when going to another page?
- Aug 31, 2009 - Is it possible to create a menu and javascript that will float when I scroll down the page.
- Sep 14, 2009 - We have errors in the drop down horizontal menu when we use two drop down horizontal menu on the one page.
- Oct 22, 2009 - Is there a way to set a menu item to pressed when a page is reloaded?
- Oct 25, 2009 - The first item of the menu dinamico html stays highlighted when I load my page.
- Dec 04, 2009 - Will the menu rollover stay in view when the user scrolls page down?
- Jan 23, 2010 - Is it possible set a pressed item when you have multiple mouse over menus on the page?
- April 29, 2010 - I want the javascript menu popup to hide when I click somewhere else on the screen.
- May 3, 2010 - How can I hide my dhtml menu horizontal on print?
- June 20, 2010 - Set a menu item of the html dropdown menu to pressed when a page is loaded.
|