Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hover Over Image, Get Print Dialog?

I have an ad placement system that randomly selects an ad image to display. The user can click on it to get to the respective website, and it has a border that appears when it is hovered over.

However, when customers hover over the ad, I want an option to appear (perhaps in the corner of the image) to print it out (the ads are coupons that may be used at brick and mortar establishments).

Or perhaps, if usability dictates, I would like a link right underneath the ad to start a print dialog.

How would I do this?

like image 706
AKor Avatar asked Dec 05 '25 00:12

AKor


1 Answers

You can use the mouseover event to determine when the user has hovered over the element, the click event to be notified when the user clicks the print link, and window.open(...) to open another page that'd have the ad just by itself, and then window.print() in the new window to print the page.

Ideally you'd want to just print without opening a new window, but I'm not aware of any cross-browser way to do this.

like image 182
Brian Donovan Avatar answered Dec 06 '25 13:12

Brian Donovan