Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stay on current window when the link opens in new tab?

Tags:

html

jquery

When a user clicks on a link

<a href="http://www.stackoverflow.com" target="_blank">click</a> 

is there a way to stay on the current window instead of going to the tab ?

like image 631
EnexoOnoma Avatar asked Sep 22 '11 23:09

EnexoOnoma


People also ask

How do I stay in the same page after clicking links?

usually href's ar used to transfer the request to another page.. If you want to redirect another page still the existing page remain open use target attribute.. If you dont want to redirect anywhere and still want send a signal while clicking the text, use onclick on the text and not the href.

How do I open a new tab without leaving a page?

Open a new tab Or, use a keyboard shortcut: Windows & Linux: Ctrl + t. Mac: ⌘ + t.

How do you force open a link in the current window tab?

Then you can just use the Open link in new tab option from the context menu or press the middle mouse button to open a link in a new tab.

How do I keep a link from opening in a new tab?

Open Link in New Tab Generally, you can hold down the control button – or the command key on a Mac computer – to open a link in a new tab. You can also click on a link and hold down the mouse without releasing, dragging the link to the browser's tab bar to open it in a new tab.


1 Answers

I guess target="_blank" would open new tab/Windows but will switch the tab as well, and no way I can find them stuff in html, Yes but when we click in link pressing control key it opens the link in new background tab, Using javascript we can stimulate same Here is code I found

function openNewBackgroundTab(){         var a = document.createElement("a");         a.href = "http://www.google.com/";         var evt = document.createEvent("MouseEvents");          //the tenth parameter of initMouseEvent sets ctrl key         evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0,true, false, false, false, 0, null);         a.dispatchEvent(evt); } 
like image 159
Adel Bachene Avatar answered Oct 13 '22 22:10

Adel Bachene