Link to home
Start Free TrialLog in
Avatar of Nebukad
Nebukad

asked on

Keep focus on window

Hi,

Given the following example, how do i keep the focus on the current page after a user clicks on the link. In other words the link should open but the focus should remain on the current page.
I tried using the window.focus function but for some reason this does not work.

<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
KEEP ME IN FOCUS<BR>
<A HREF="http://www.google.com" TARGET="_blank">Link</A>
</BODY>
</HTML>

Open in new window


Any help would be appreciated.

Kind regards,
Nebu
Avatar of darren-w-
darren-w-
Flag of United Kingdom of Great Britain and Northern Ireland image

<html>
    <head>
        <title>test</title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
        <style type="text/css">
        </style>
        <script type='text/javascript'>
            $(function(){                 
               $('a').click(function(){
                   window.open(this.href)
                   $(window).focus();
                
                   return false;
               })
            });

        </script>
    </head>
    <body>
        <a href="http://www.google.com" target ="_blank">location</a>
    </body>
</html>

Open in new window

Avatar of Nebukad
Nebukad

ASKER

Thanks for your response darren-w but unfortunately this does not work.
SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial