0

Does anyone have any advice on how I would open a new tab in google chrome, using the Chrome Tabs API. I've been trying to do this in my Google Chrome extension, like so

<form>
    Which page would you like to visit? <br />
    <input type="text" id="channel" name="channel" placeholder="url">
    <input type="button" value="button name" chrome.tabs.create="('#input from id="channel"')" />
</form>

but this doesn't seem to do the trick. Can anyone see what I'm doing wrong? (ignore the #input from id part, I know that won't work).

Thanks in advance

Matthew Spence
  • 986
  • 2
  • 9
  • 27
BGroat
  • 149
  • 1
  • 6
  • Try changing `` to ``. Used [this](http://stackoverflow.com/questions/16862479/chrome-extension-create-new-tabchrome-tabs-create-and-executescript-in-new-ta) – Matthew Spence Feb 12 '16 at 21:34
  • 1
    @TheMintyMate That won't work in an extension, because "onclick" isn't allowed. OP needs to remove all the javascript into a separate js file and load that with a script tag. – Teepeemm Feb 12 '16 at 22:24
  • How would I set up the listener to identify that the button was clicked in popup.html though? – BGroat Feb 12 '16 at 22:33

1 Answers1

1

If you don't HAVE to use chrome extension

<input type="button" onclick="window.open(document.getElementById('channel').value,'_blank')" />

_blank is the argument needed to open on a new tab.

D--
  • 86
  • 6
  • Which page would you like to visit?
    Is what I have no, and it isn't working
    – BGroat Feb 12 '16 at 21:47
  • Ah sorry forgot to mention that you want to use the actual url of the place you want to visit in place of the url. I'll edit accordingly – D-- Feb 12 '16 at 21:49