I am trying to click a button to refresh the current page using the chrome extension.
(NOTE: The reason is that I downloaded the script and I need a page to update, because for now I just have a disclaimer of โyou need to refresh the page for it to work,โ but I would like to remove this disclaimer and just do it automatically).
I can not understand. Here is my code I'm trying to update. If you know a way to eliminate this code and just use onclick, that's great too, but I tried onclick="location.reload();" but it doesnโt work because it does not retrieve the actual tab, but only a popup.
background.html
chrome.browserAction.onClicked.addListener(function (activeTab) { var newURL = toggleDevMode(activeTab.url); chrome.tabs.update({ url: refresh }); });
refresh.js
document.getElementById("mydivtoclicky").onclick = function() { chrome.tabs.getSelected(null, function(tab) { tabId = tab.id;
popup.html
<head> <script type="text/javascript" src="../refresh.js"></script> </head> <body> <div id="mydivtoclicky">REFRESH PAGE</div> </body>
Please help thanks.
source share