Recently I had a user request to print out the main display window in our content management system from the left navigation window. I remembered doing this years ago but could not get the script right from memory so I hit the web. This was a common problem yet most of the suggestions did not work for me or countless others. Eventually I remembered something about needing to access the top level window in the window hierarchy when making a call from one frame to another and produced the following script that worked like a charm:
window.top.frames[1].focus();
window.top.frames[1].print();
You need to bring focus to the frame/iframe you want to print before calling the print method otherwise the frame that has focus will print out instead.
No comments:
Post a Comment