How to open links in a new tab only when the link points to specific websites of my choosing?
I want to be able to open some links (with single click) in new tabs, but only for specific websites of my choosing. I want something that works as follows: - if I set website www.thewebsiteilike.com as "new tab on link click", then any link pointing to this website will open in new tab - but, clicking a link pointing to other website will open in its default behavior... usually replace the tab.
すべての返信 (8)
Something additional: - I know right click allows this from context menu and that middle click does it by default.
BUT: either method requires more thinking. I want to be able to do it automatically (done for me) without a 2nd thought.
For the most part, the way tabs are opened relies on how the website tells the browser to open them. In the case of Firefox, it opens links in new tabs when the website (or user) tells it to, and opens new windows in a new tab (if selected in options)
Certain websites (mainly search engines) will let you set preferences for opening links in new tabs or not. Google and Bing both let you set preferences to open results in a new window, and Firefox can be set to open those new windows in new tabs.
I'm assuming search engines are the main websites you want to open new tabs from, and I realize that most websites don't have preferences like this. Maybe you can find an addon that could help. I looked, but only saw addons to open all links in new tabs, and those didn't even work properly.
Hi SuperSluether,
Thanks for your reply.
Actually no. I need this for work. I handle lots of trouble cases on a daily basis and am fed up of "losing" the main page every time I click on a case to handle. I waste a lot of time going back to the case home and reloading the ticket list.
Tried right click + open new tab or middle click.... but I manage to make it 50% of the time... can't remember to do it all the time.
Tried some add-ons but none worked. I gave up on searching add-ons when I installed one that made it impossible to follow ANY link even on the same tab...
I asked hoping someone knows of an add-on that does this among the thousands there are...
Someone could write a custom user script for you, that you would run using the Greasemonkey extension.
The idea would be to check all the links in the page and any which does not already have target="_blank" would have that added. Or it may be that you want site links to stay in the same tab, and only external links to open in a new tab. You'll want to be as specific as possible with the request.
You can request new userscripts on either of these forums:
Ok, looking at some of the addons again, I found one that might help: https://addons.mozilla.org/en-US/firefox/addon/open-link-in-new-tab/
It opens links in new tabs based on certain conditions like difference websites, domains, hosts, scripts, things like that. It doesn't give you control over individual websites though.
Thanks SuperSleuther. Unfortunately that is exactly the AddOn that made it impossible to open any link...
Thanks jscher2000. I will explore that option. AT this time I need this "feature" for only one single site, so I guess/hope it should not be too complex?!
still... I will once again search on Add-ons too. Maybe I find one obscure Add-on that someone wrote for the kick of it...
Ok. Greasemonkey was the way to go. Thanks!
I do coding on several other things... never javascript... but decided to go for it.
For a moment I almost gave up when I saw the page was built dynamically with javascript so there really were no URLs to search for and translate...
But then found how handle the click event. The page is tricky on how it's built... but anyway a 10 line little script did the trick and it covers 85% of what I need. I can improve it and build on it later...
Many thanks for your help!
Hi leohussey, glad to hear you find a solution.
Not sure it's relevant to your target page, but if the page adds links after your script runs, you can look at the method used in this script to catch those: https://greasyfork.org/scripts/1681-google-cache-highlight-search-query-terms-for-https/code (lines 63-90; you'll need to customize line 81 to find the relevant links in your page, and line 88 to run your function instead of mine).