javascript - Linking to chrome://history through extension -
i'm working on chrome extension injects few buttons onto page via content script, , have button links history page (chrome://history).
this opens blank tab no url:
window.open("chrome://history", "_blank");
and having hyperlink history page directly give me error:
<a href="chrome://history" target="_blank">...</a> not allowed load local resource: chrome://history/
chrome's extension api doesn't have chrome://*
listed supported scheme extension pages, explains error, want provide link history page. there way this, if it's little (or lot) convoluted?
thanks!
edit: added done through content script, didn't clarify in initial post.
wolf war's answer correct, however, content script additional step needed.
you need background (or better, event) page process request, since content scripts can't call api. need use messaging:
// content script // element dom element element.addeventlistener("click", function(e) { chrome.runtime.sendmessage({command: "openhistory"}); }); // event script chrome.runtime.onmessage.addlistener(function(message, sender, sendresponse) { if(command == "openhistory") { chrome.tabs.create({'url': 'chrome://history'}); } });
Comments
Post a Comment