简体   繁体   中英

chrome extension - manifest version 2

I developed manifest version 1 of a chrome extension which takes input from user and open a new window

But when I upgraded to manifest version 2 the redirection to www.someUrl.com in a new tab is stopped.

Please tell me what changes I have to do according to version 2 to make it run.

popup.html

<body onload="document.form.query.focus()";>

<div id="searchwrapper">

<script>
function send_url() {   
    var url = "www.someurl.com?query="+form.query.value;
    window.open(url, '_blank'); 
    return false;
}
</script>
<form name="form" id="search_form" action="popup.html" method="POST">
<input type="text" class="searchbox" name="query" value=""/>
<input type="hidden" name="search" value="1">
<input type="image" src="search.png" onClick="send_url()" value=""/>
</form>
</div>

</body>

and my manifest.json

{
"manifest_version": 2,
"name": "Search",
"version": "2.0",
"description": "This is a chrome extension for search",
"browser_action": {
  "default_icon": "icon.png",
  "default_popup": "popup.html"
},
"permissions": ["www.someUrl.com"]
}

No inline scripts is allowed in Manifest2. Manifest 2 also disallow

onClick="send_url()"

Change

"version": "2.0",

to

  "manifest_version": 2,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM