How to open a link in same tab in browser extension popup?

Viewed 16

I want to open the link in same tab when I click on popup of extension.

manifest.json

"action": {
        "default_popup": "popup.html"
    },

popup.html

<!DOCTYPE html>
<html lang="en">

<head>
  <link rel="stylesheet" href="popup.css">
</head>

<body>
  <div class="wrapper">
    <h2>Welcome </h2>
    <button type="button" class="button_style" id="btn1">Connect</button>
  </div>
  <script src="popup.js"></script>
</body>

</html>

popup.js

var button = document.getElementById("btn1");
button.addEventListener("click", function () {
    chrome.tabs.create({ url: "https://www.youtube.com/" });

});

Currently I am doing this

chrome.tabs.create({ url: "https://www.youtube.com/" });

But it open a new tab . How can I open the url in same tab (in which I open the popup)?

0 Answers
Related