Some websites open links in a new tab, and I find this incredibly annoying. Is there any way to force links to open in the same tab, instead of opening a new one?
How to make links open in same tab? - Google Chrome Community
Open links in same tab in Chrome - Google Chrome Community
Chrome Extension: How do i open urls in popup.html in the same tab - Stack Overflow
Is there a way to force any links to open in the same window of the browser?
There is a 3 step workaround you can do this by
- You should know when the popup will be opened. Popups are blocked in chrome by default. But chrome will show a popup blocked notification in bottom right corner.
- click on notification to select always accept popup from this specific site
- Reload the main (parent) page. This will load the popup in small windows. Right click in titlebar of popup window and select "Show As Tab". Once popup is transformed in a window with tab, you can drag it back to main window.
Hope this helps.
Thanks.
There is the chrome extension One Window.
It is not perfect, as the popup will first be opened and then "transformed" into a tab, which you will see as a flicker. Otherwise it seems to work fine.
I believe that chrome does not allow the popups to open an external page by any way. The only solution I know is to place an iframe in your popup.html file with src attribute set to popup2.html and place all your html inside popup2.html. However, consider that all websites do not work well inside iframe.
If you are trying to open url in currently active tab then try following:
Attach following script to your popup.html file:
var hrefs = document.getElementsByTagName("a");
function openLink() {
var href = this.href;
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
var tab = tabs[0];
chrome.tabs.update(tab.id, {url: href});
});
}
for (var i=0,a; a=hrefs[i]; ++i) {
hrefs[i].addEventListener('click', openLink);
}
You need to add tabs permisson to your manifest file for this to work.
You only need to use chrome.tabs.update({active: true, url: 'yoursite.com'}); instead of chrome.windows.create({url:'yoursite.com'}); and the location will be opened in the same active tab
There is an extension called OpenHere that will do this. It will add the option in the right click context menu Open in This Window. Just right clcik on the link you want to open in the same tab.
Edit in response to comment:
You can do it with AutoHotkey. You have need to download it and install it on your PC. After that just copy the code below and save it with a .ahk extension.
SetTitleMatchMode, RegEx
#IfWinActive, - Google Chrome$
!RButton::
!LButton::
KeyWait, Alt
Click, Right
SendInput, e
ControlFocus, Chrome_OmniboxView1
SendInput, ^a{Backspace}
SendInput, ^v{Enter}
return
#IfWinActive
Now when you press Alt + LClick, it will copy the link to the clipboard and past it in the address bar of Chrome. Just press the button and click and release with the click and the link will open in the same tab.
If autohotkey is is the way you want to go, there's a much simpler way of doing it:
#IfWinActive ahk_exe chrome.exe
!LButton::
Send, ^{LButton}
Send, ^{F4}
return
#IfWinActive
This just ctrl-clicks wherever the mouse is and then closes the current tab when you alt-click anywhere on a chrome tab. And since it isnt sophisticated enough to activate ONLY when clicking on a link, you could also use it as a shortcut to close the current tab by alt-clicking anywhere on the tab.
Looking for a solution to force any links to open in the same window of the chrome browser instead of opening in a new window.
Holding Ctrl+Left click doesn't work for all kinds of links.
"Open link in the same tab, pop-up as tab" extension doesn't work on some links.