Sjmon
04-27-2005, 11:14 AM
I have the following function to open the current page in a new window, hide navigation bar and print the page when a user clicks a link. This works well if the page in the new window loads instantly, but if the page takes a while to load, then it doesn't work since it tries to hide the nav bar and print before the page is loaded. I could use the setTimeout function and put onload event handler in the body tag that notifies the opener when it's done loading, but I'd like to know if there's any other way to handle this without adding onload event to the body tag.
<SCRIPT language=JavaScript>
function printerFriendlyView()
{
var printerFriendlyViewWin = window.open(document.URL, "", "toobar=0,scrollbars=1,alwaysRaised=1,width=600,height=600,resizable=1");
printerFriendlyViewWin.document.getElementById('nav').style.display='none';
if (navigator.appName=="Microsoft Internet Explorer"){
printerFriendlyViewWin.print();
} else{
printerFriendlyViewWin.refresh();
printerFriendlyViewWin.print();
}
}
</SCRIPT>
<SCRIPT language=JavaScript>
function printerFriendlyView()
{
var printerFriendlyViewWin = window.open(document.URL, "", "toobar=0,scrollbars=1,alwaysRaised=1,width=600,height=600,resizable=1");
printerFriendlyViewWin.document.getElementById('nav').style.display='none';
if (navigator.appName=="Microsoft Internet Explorer"){
printerFriendlyViewWin.print();
} else{
printerFriendlyViewWin.refresh();
printerFriendlyViewWin.print();
}
}
</SCRIPT>