Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Keep focus on window

Posted on 2011-03-23
Medium Priority
Last Modified: 2012-05-11

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.

<A HREF="" TARGET="_blank">Link</A>

Open in new window

Any help would be appreciated.

Kind regards,
Question by:Nebukad
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 13

Expert Comment

ID: 35197785
        <script type="text/javascript" src=""></script>
        <style type="text/css">
        <script type='text/javascript'>
                   return false;

        <a href="" target ="_blank">location</a>

Open in new window


Author Comment

ID: 35198064
Thanks for your response darren-w but unfortunately this does not work.
LVL 82

Assisted Solution

leakim971 earned 200 total points
ID: 35198595
>but for some reason this does not work

for security purpose

check if you like this :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<A HREF="" onclick=";">Link</A>

Open in new window

LVL 13

Accepted Solution

darren-w- earned 1800 total points
ID: 35198643
This opens a window, but keeps the parent in focus

        <script type="text/javascript" src=""></script>

        <script type="text/javascript">
            function popitup(url) {
                if (newwindow.focus) {window.focus()}
                return false;

            // -->
        <a onclick="return popitup(this.href)" href="" target ="_blank">location</a>

Open in new window


Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question