I am developing a chrome extension where I want to inject a button on a web page. On clicking the button I want to call chrome.tabs.create API to open an HTML page into new tab.
As we know we can't directly open the tab using the content script, so what is the solution for implementing the above functionality.
Lets say I am having an element name "button" injected on the button i have added the evnetHandler using following code but how to use this function to create the new tab in background.js
button.addEventListener('click',clickhandeler,true);
manifest.json file:-
{
"name": "my chrome extension",
"version": "1.0",
"manifest_version": 2,
"description": "open the tab when button is cllicked",
"permissions":["activeTab","tabs"],
"background": {
"scripts": ["event.js"],
"persistent": false
},
"browser_action": {
"name": "Manipulate DOM",
"default_icon": "icon.png"
},
"content_scripts": [ {
"js": [ "jquery.min.js", "inject.js" ],
"css": [ "inject.css" ],
"matches": [ "http://*/*", "https://*/*"]
}]
}