Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6228443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:23:22+00:00 2026-05-24T09:23:22+00:00

I have a print icon (image) which, when clicked, calls window.print(); . However, I

  • 0

I have a print icon (image) which, when clicked, calls window.print();. However, I also have a hover event for this same print icon, which changes the image src (gradient effect).

The code:

   $( "#print_icon" ).hover(

    //mouseover
    function(){
        $( this ).attr( "src", "http://example.com/images/image1.png" );
    },

    //mouseout
    function(){
        $( this ).attr( "src", "http://example.com/images/image2.png" );
    });

// print onclick//
$( "#print_icon" ).click(function() {
    window.print();
});

The problem:

Without clicking, the hover works as intended. When someone clicks the image, the print window appears, but the “mouseout” function doesn’t run until the print window is dismissed. I’d like to change this behavior, so that the mouseout function will run even if the print window is active, or displayed.

Is this possible?

UPDATE

still doesn’t work as intended:

$( "#print_icon" ).hover(

    //mouseover
    function(){
        $( this ).attr( "src", "http://library.weill.cornell.edu/prc/images/print_icon_onclick.png" );
        $( this ).click(function() {
            window.print();
        });
    },

    //mouseout
    function(){
        $( this ).attr( "src", "http://library.weill.cornell.edu/prc/images/print_icon.png" );
    });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:23:23+00:00Added an answer on May 24, 2026 at 9:23 am

    In all browsers I know of, window.print() launches a modal print window — that is, a window that prevents all other interaction with the web page until it is closed. This is by design — the browser is grabbing a snapshot of the web page as it was rendered when the print operation began.

    In short, there is no way to trigger mouseout events while the print window is open.

    The best alternative would be to trigger the mouseleave event in your click handler before starting the print operation:

    // Click Handler
    $( "#print_icon" ).click(function() {
      $(this).mouseleave();
      window.print();
    });
    

    You will most likely move your mouse off the button anyway to select your printer settings, so for practical purposes, this will fix the problem.

    Update

    setTimeout() can modify the page while the modal window is open — at least in Firefox 5. Try this:

    // Click Handler
    $( "#print_icon" ).click(function() {
      var that = this;
      setTimeout( function() {
        $(that).mouseleave();
      }, 2000);
      window.print();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a div section in which I have an image whose onclick event
I have written a function to print database table to an array like this
I have a listview control, to this control I am adding rows which contain
I have loaded a jpg image in which I want to draw letters and
I have a link button: <asp:LinkButton ID=LinkButtonPrint runat=server OnClick=OnPrint_Click> <img src=img/print-icon.png alt= /> <asp:Literal
i have an iframe: <iframe name=printarea id=printarea src=print.php style=display: none;></iframe> i need this iframe
I have a link tag which assignes a bookmark icon to the page: <link
First I have these variables: $asd=$current[0]->icon['data']; // -it will print /ig/images/weather/mostly_cloudy.gif $icons[/ig/images/weather/rain.gif][0]; // it
I currently have implemented an overlay item that shows an icon for Geo-point on
I have a situation where I have to print out a NUL character if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.