user2597417
user2597417

Reputation: 99

Creating a search bar in a chrome extension that will open in a new tab

I am trying to create a google search bar in a chrome extension that will open the search in a new browser tab. My manifest.json looks like this:

{
 "name": "Search",
 "version": "1.0",
 "manifest_version": 2,
 "description": "Search",
 "browser_action": {
 "default_icon": "search.png",
 "default_popup": "popup.html"
   }
}

My HTML looks like this:

<div id="search">
<form method="get" action="http://www.google.com">
<div style="border:0px solid black;padding:2px;width:20em;">
<table border="0" cellpadding="0">
<tr><td>
<input type="text"   name="q" size="25"
 maxlength="255" value=""<textarea placeholder="Search Google"></textarea>
<input type="submit" value="Search" /></td></tr>
</table>
</div>

This html page works fine in a normal browswer but not as a chrome extension. I think that I need to give permission to access my tabs but I am new to making chrome extensions so I am having a little bit of trouble with my rigid manifest.json markup.

Upvotes: 3

Views: 4675

Answers (1)

user2384183
user2384183

Reputation:

Add a target="_blank" attribute to your form, like so:

<form method="get" action="http://www.google.com" target="_blank">

(MDN Reference)

Upvotes: 3

Related Questions