Thursday, July 26, 2012

Asp.net jQuery Page Focus Event Handler


The page Focus event can be handled using jQuery by adding a handler to the jQuery focusin event as follows.

$(document).bind("focusin", function(event) {
// Add your code here.
});

Example

Note: Change the reference of the jQuery
jquery-1.7.2.js files to point to your local directory.

<
html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Page Events</title>
    <script type="text/javascript"
src="JavaScript/jquery-1.7.2.js"></script>
    <script type="text/javascript"
language="javascript">
    $(document).ready(function() {
        $(document).bind("focusin", function(event) {
            alert('Focus on Page');
        });
    });
    </script>
</head>
<body>
    
</body>

Search Flipkart Products:
Flipkart.com

1 comment:

Anonymous said...

Thanks for the solution.
But this solution is not working for Firefox.
Do you have a solution for that?