Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome extension: Navigate to a url when user clicks on icon

Is there any way to exexute a javascript, that navigates the browser to some url, when user clicks on extension icon?

like image 863
Prakash GPz Avatar asked Dec 31 '12 12:12

Prakash GPz


People also ask

How do I enable URL access in Chrome?

Right-click the extension's icon located in the toolbar and then select “Manage Extensions.” Scroll down until you see “Allow Access to File URLs” and toggle the switch to the “On” position.

How do I link to a specific part of a page in Chrome?

To use the feature, visit a web page and simply highlight the text you want to create a link to, then right-click and choose Copy Link to Highlight from the dropdown menu. This will generate a URL that includes a hash (#) symbol.

What does on Click mean Chrome extension?

On click — meaning the extension is able to see and alter what's in your browser only when you actively click it (and then only for the site that's currently open in that specific tab)


1 Answers

You can use the following code:

chrome.tabs.update({
     url: "http://www.example.com/"
});
like image 78
Thomas C. Rodriguez Avatar answered Sep 23 '22 17:09

Thomas C. Rodriguez