View Full Version : Print Button?

09-05-2006, 08:03 PM

I am creating a site that uses frames, and I am going to make some materials that need to be printed, but it sucks when you have the frame printed on the materal as well. Is there a way in javascript to make a button in one of the sites so that people can just click to print out whats on that window of the frame?


09-05-2006, 09:02 PM
I guess what you could do is have a button which calls window.open which opens the page that the button is on then call the print function

<input type="button" onclick="newwin=window.open(window.location.href);if(newwin)newwin.print();" value="Print">
I haven't tested the above. Its just a thought.

09-05-2006, 09:07 PM
Thanks! That works. Do you think there is a way for it to work without popping the new window up? Or does it have to in order to print without the frame?


09-05-2006, 09:13 PM
You might be able to do something like

<input type="button" onclick="window.frames['framename'].print()" value="Print">
If the page is on the same domain that should work. If it dosen't then try

<input type="button" onclick="parent.window.frames['framename'].print()" value="Print">