'Refresh all open chrome tabs on a button click event in asp.net

My Requirement - If I am opening multiple localhost tabs with the same url and if I am clicking on a button inside any tab, I want all the tabs to refresh.

Here I have a add button (for a simple add function), so while clicking it I want the additon to happen also want all the tabs to refresh. (I have not included the c# code for addition)

My source code:-

<script type="text/javascript">
  function Refresh()
  {
    chrome.tabs.query({windowType:'normal'}, function(tabs) {
      for(var i = 0; i < tabs.length; i++) {
        chrome.tabs.update(tabs[i].id, {url: tabs[i].url});
      }
    }); 
    return false;
  }
</script>

<asp:Button ID="Button1" runat="server" onClick="Button1_Click" OnClientClick= "Refresh()" Text="Add" />

What I am getting is: Cannot read properties of undefined(reading 'query') at Refresh, at HTMLInputElement.onClick

The add function works fine but the refresh is not happening.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source