1

I am browsing some websites, I can click (for example in Chrome) on the link with the right button and choose OPEN IN THE NEW TAB -> the tab is opened, but in the background (the current tab stays as the main tab).

I am trying to do with the link - I added to the link the attribute target="_blank", but always as the main tab is displayed the new one - not the tab from which I opened the new tab.

Is there any way, how to do that?

EDIT: What I am trying:

javascript.js
    $(document).ready(function(){
      $('a[target="_blank"]').removeAttr('target');
      ...
    })

<a href="http://www.google.com" id="id_attribute">link</a>

But the page is always opened in the same window...

user984621
  • 46,344
  • 73
  • 224
  • 412
  • Check these questions: http://stackoverflow.com/questions/10812628/open-a-new-tab-in-the-background http://stackoverflow.com/questions/7386208/open-a-new-browser-tab-in-background-programmatically – ainokna Oct 10 '12 at 07:38
  • Here's the answer : http://stackoverflow.com/questions/7522565/how-to-stay-on-current-window-when-the-link-opens-in-new-tab – Laurent Brieu Oct 10 '12 at 07:38
  • 1
    try to search better before posting duplicate questions – ainokna Oct 10 '12 at 07:40

1 Answers1

-1

You must remove the link's target attribute:

  $('a[target="_blank"]').removeAttr('target');

Then it will stay in the same window without changing to the new one that opens by clicking the link.

mram888
  • 4,899
  • 5
  • 33
  • 59