Chrome extension; open a link from popup.html in a new tab

google chrome open link in same tab automatically
chrome extension open new tab
open link in new tab chrome extension
chrome extension open new tab from background
chrome extension popup
chrome extension open popup from content script
chrome extension default popup
chrome opening new windows instead of tabs

I'm doing a Chrome extension and I got helped in this post here.

My problem now is how to open a new tab of chrome that has as URL the link I clicked in the popup.html. I tried to do like someone suggested in their answers in other similar question like setting <a>'s attribute target to _blank but the only result is that chrome does open a new tab but in the new tab is my popup.html.

Any idea how to solve this?

Thanks.

You should use chrome.tabs module to manually open the desired link in a new tab. Try using this jQuery snippet in your popup.html:

$(document).ready(function(){
   $('body').on('click', 'a', function(){
     chrome.tabs.create({url: $(this).attr('href')});
     return false;
   });
});

Open link in same tab, pop-up as tab [Free], Forces Chrome to open new tabs instead of pop-up windows and/or links in the same tab by default instead of new or background tab. a new or a new background tab, or even in a new window, then this extension is for you. If you haven’t yet, sign in to Chrome. Find the extension you want. Tap Add to Desktop. Confirm by tapping Add to Desktop. The next time you open Chrome on your computer, you’ll see a message that the extension was installed. If the extension needs some permissions, you'll be asked. To approve, click Enable extension.

See my comment https://stackoverflow.com/a/17732609/1340178


I had the same issue and this was my approach:

  1. Create the popup.html with link (and the links are not working when clicked as Chrome block them).
  2. Create popup.js and link it in the page: <script src="popup.js" ></script>
  3. Add the following code to popup.js:

    document.addEventListener('DOMContentLoaded', function () {
        var links = document.getElementsByTagName("a");
        for (var i = 0; i < links.length; i++) {
            (function () {
                var ln = links[i];
                var location = ln.href;
                ln.onclick = function () {
                    chrome.tabs.create({active: true, url: location});
                };
            })();
        }
    });
    

That's all, links should work after that.

Chrome extension- how to open popup.html in a new tab? : webdev, I tried googling the problem but all of the answers pertain to opening a LINK within a popup on a new tab. I want the popup to spawn entirely on a new tab. Netflix Party is a Chrome extension for watching Netflix remotely with friends, e.g., for movie nights with that long-distance special someone. It synchronizes video playback and adds group chat. As of Apr 16 2020, Version 1.7.9 of Netflix Party is available.

If you don't want to use JQuery, insert this into your popup.js and it will make all your links open in a new tab when clicked

Remember to declarer the "tabs" permission in the manifest.json

window.addEventListener('click',function(e){
  if(e.target.href!==undefined){
    chrome.tabs.create({url:e.target.href})
  }
})

Chrome extension; open a link from popup.html in a new tab, My problem now is how to open a new tab of chrome that has as URL the link I clicked in the popup.html. I tried to do like someone suggested in their answers in � Now, browse to the Chrome Web Store and find an extension you’d like to install. All you have to do is click “Add to Chrome.” Click “Add Extension” in the confirmation dialog—just like if you were installing the extension in Chrome. Remember that any extensions you install from the Chrome Web Store weren’t tested for the Edge browser.

The other answers work. For completeness, another way is to just add target="_blank"

Or if you have want to "manually" add particular links, here's a way (based on the other answers already here):

popup.html

<a id="index_link">My text</a>.

popup.js

document.addEventListener('DOMContentLoaded', () => {
   var y = document.getElementById("index_link");
   y.addEventListener("click", openIndex);
});

function openIndex() {
 chrome.tabs.create({active: true, url: "http://my_url"});
}

Chrome Extension: onclick extension icon, open popup.html in new , Chrome Extension: onclick extension icon, open popup.html in new tab to open up the popup.html, in a new tab, you would need to pass in the extension url. The Great Suspender is a lightweight chrome extension to help reduce chrome's memory footprint for users that like to have too many tabs open at the same time. This extension will automagically

A bit more concise version in modern JS:

document.addEventListener('DOMContentLoaded', function () {
  for (const anchor of document.getElementsByTagName('a')) {
    anchor.onclick = () => {
      chrome.tabs.create({active: true, url: anchor.href});
    };
  };
});

How to Open a New Tab When Clicking a Link in Google Chrome , Opening links in a new tab with a single click of your mouse may make heavy Web The Chrome Toolbox extension gives you more control over Chrome's settings. device or another device with a touchscreen, press and hold the link to make this menu pop up. add the attribute target= "_blank" to the HTML tag, such as. The Chrome Extension Overview backs up a bit, and fills in a lot of detail about the Extensions architecture in general, and some specific concepts developers will want to be familiar with. Learn about the options available for debugging Extensions in the debugging tutorial. Chrome Extensions have access to powerful APIs above and beyond what's

Sample Extensions, platformKeys | events | extension | extensionTypes | fileBrowserHandler A browser action with a popup dump of all bookmarks, including search, add, edit and Download Selected Links Type 'nt' plus a search term into the Omnibox to open search in new tab. Shows a page action for HTML pages containing a video. Chromed Bird is an open source Chromium extension that allows you to follow your Twitter account using Google Chrome. ***** ATTENTION ***** As the official Google Chrome extensions gallery is open I'll STOP updating this website.

How to display HTML page from my website in default popup of , For other tutorials, see the web. Or try this on how to show a popup window when you click on your Chrome extension icon in your Chrome web� A new way to watch Netflix together. Netflix Party is a new way to watch Netflix with your friends online. Netflix Party synchronizes video playback and adds group chat to your favorite Netflix shows.

How to programmatically open chrome extension popup.html, html, in a new tab, you would need to pass in the extension url. chrome.tabs. create({'url': chrome.extension.getURL('popup.html')}, function(tab) { // Tab opened. });. chrome remote desktop. Remote Access. Remote Support. Your desktop anywhere. Securely access your computer from your phone, tablet, or another computer. It's fast

Comments
  • Possible duplicate of How to make popup.html links open in tab?
  • Shouldn't that a's attribute I put as URL 'href'. Bytheway it doesn't work in both cases. It opens me a tab with this url: chrome-extension://ceapmkdonphjngfdcjcoahdmkenpbgpn/?action=read&idnotizia=71189
  • You are right about 'href', sorry for that - i fixed my answer. You need to supply full url in href if you want it to open. Currently you have links like this <a href='?action=read&idnotizia=71189'> change them to full URLs <a href='http://yoursite.com?action=read&idnotizia=71189'>.
  • I thought it was a problem with my extension. I concatenated the domain name to the string and now works perfectly.
  • Note this only works for links that exist in the document at load time, and is also very inefficient. To catch ALL link clicks efficiently, no matter when the link appeared, use $('body').on('click', 'a', function ()...
  • I use the same javascript for options.html and popup.html, this code solves the problem for popup.html but also causes trouble for options.html when it opens two tabs for the same link (because options.html doesn't need that fix), but I don't want to use separate js files, do you have any idea how to solve it?
  • seems I found a solution to check if page is popup or options: if (chrome.extension.getViews({ type: "popup" }).length > 0) { // execute your code }
  • also we need this only for Google Chrome and Opera, but we should not add this code in Firefox extensions (WebExtensions) cause in Firefox it works fine without any fix, if you add it, it will open two tabs with Firefox extension
  • I'd suggest to use the "activeTab" permission instead: developer.chrome.com/extensions/activeTab
  • whoah this needs more attention.. :)
  • Can confirm that target="_blank" behaves as expected on both Firefox (version 72) and Chrome (version 79).