Chrome extension: open a new tab from a form in a popup

I have a simple javascript form in a chrome popup. When you click on the extension icon, the user fills out the form and clicks "go!", In which a new tab should open - the URL for this new tab will be determined in accordance with the values ​​in the form.

Currently, the popup is displayed in order and the form values ​​are populated in order. How to open a tab when user clicks a button?

(I'm new to javascript, and the documentation confused me from me: |)

manifest.json:

{ "name": "My Helper", "version": "1.0", "description": "My Helper", "background_page" : "background.html", "browser_action": { "default_icon": "icon.png", "popup": "popup.html" }, "permissions": ["tabs"] } 

popup.html:

 <html> <head> <script type="text/javascript"> // some functions... </script> </head> <body> <form name="frmOne"> // input fields <button type="button" onclick="buildTheUrl(..input values..)">Go!</button> </form> </body> </html> 

background.html is currently empty.

+6
source share
1 answer
 chrome.tabs.create({url: 'http://pathToYourUrl.com'}); 
+11
source

Source: https://habr.com/ru/post/886066/


All Articles