views:

106

answers:

2

Hi all,

I would like to know if it's possible to use javascript to open a popup window containing an image, and at the same time have the print dialog show. Once someone clicks on print, the popup closes.

Is this easily attainable?

A: 

Yea, just put the image on the screen, and then call window.print(); in javascript and it should popup.

(This is how Google Maps/Google Calendar do printing)

webdestroya
Cool. But what if I want a different image to show that initiates the popup window?
andrew
Check out the CSS styles for printing. You can basically have an image hidden on the screen view, and then visible for the print view.
webdestroya
+1  A: 
popup = window.open();
popup.document.write("imagehtml");
popup.print();
Javier Parra
How would this work using a button? The button would initiate this action, but actually prints a separate image.
andrew
I'm not going to write all the code for you, the point of this place is to learn. ;)You'd do it using the onmouseup event on the button:http://www.w3schools.com/jsref/event_onmouseup.asp
Javier Parra
I don't want you to write it for me... just want to be pointed to the right resources. I need a place to start. Thanks.
andrew