window.print in Firefox

  • Thread starter Thread starter David C
  • Start date Start date
D

David C

I have an aspx page that displays a GridView and some buttons, etc. One of
the buttons is to print the web page but hides some controls first via the
following Javascript:

function printplanner()
{
document.getElementById("Calendar1").className = 'visno';
document.getElementById("LblCalendarInfo").className = 'visno';
document.getElementById("newmenu").className = 'visno';
document.getElementById("BtnShowCal").className = 'visno';
document.getElementById("BtnPrint").className = 'visno';
document.getElementById("BtnEmailPlanner").className = 'visno';
document.getElementById("BtnReturn").className = 'visno';
window.print();
document.getElementById("Calendar1").className = 'visyes';
document.getElementById("LblCalendarInfo").className =
'visyesred';
document.getElementById("BtnShowCal").className = 'visyes';
document.getElementById("BtnPrint").className = 'visyes';
document.getElementById("BtnEmailPlanner").className = 'visyes';
document.getElementById("BtnReturn").className = 'visyes';
return false;
}

This works fine in IE but not Firefox. I thought getElementbyId was common
to all browsers. Below is the css class for visno, if this helps.

..visno
{
display: none;
visibility: hidden;
}

How can I get it to work in Firefox (and others?)? Thanks.

David
 
What happens is the window.print() works, but the statements (changing
controls back to css of visyes) following it do not make the controls
visible like they do in IE.

I found some notes about using setTimeout which gets the print ok but does
not make them visible.

David
 
What happens is the window.print() works, but the statements (changing
controls back to css of visyes) following it do not make the controls
visible like they do in IE.

I am still not sure why you even want to do this Javascript, instead of
simply linking an additional stylesheet...?

Anyway, I do not believe that it is specified anywhere if the
window.print() function is expected to return immediately or wait for the
printing to complete. Thus, depending on the user agent, you might not get
any notification when the client is done printing. Switching the styles
back after n seconds might just work, given that the print is started
within n seconds from clicking the button.
 
Back
Top