Hi,

I was trying to make a printer friendly page, I've gone through several possibilities. At the moment I'm trying to just change the CSS, which sort of works, but there is a problem. When the user clicks the print link, it hides a bunch of stuff that I don't want printed, then in the JS I call window.print(), and then I show all the elements again. This way it still prints everything. If I comment out everything after the print call it prints fine. Is there a way to delay the rest of the function until the page is sent to the printer? The only thing that came to mind is setTimeout but this is a horrible idea! This is the function I'm using.

Code JavaScript:
function openPrinterFriendly() {
 
    hideElement('mediabar');
    hideElement('mainTopicsContainerDiv');
    hideElement('mainSearchContainerDiv');
    hideElement('topThumbnails');
 
    var topics = getObject('mainTopicsContainer');
    var wt = topics.style.width;
    topics.style.width = '0px';
 
    var search = getObject('mainSearchContainer');
    var ws = search.style.width;
    search.style.width = '0px';
 
    document.body.style.backgroundImage = '';
 
    window.print();
 
// if I comment the rest out, it works fine, but then I'll require another click  from the user to get the site back to normal
    document.body.style.backgroundImage = 'url(http://www.site.com/images/mediabar/topmenbg.gif)';
 
    topics.style.width = wt;
    search.style.width = ws;
 
    showElement('mediabar');
    showElement('mainTopicsContainerDiv');
    showElement('mainSearchContainerDiv');
    showElement('topThumbnails');
}

Thanks