0

i want to create a button on a popup page that redirect to google search page when clicked so i used window.open this is the html

<li> 
    <input type="image" src="http://www.google.com/s2/favicons?domain=www.google.com" onClick="google()">
</li>

and the javascript

function google(){ 
    window.open("http://www.google.com/search?q="+document.search.query.value);
}

this works fine when i preview the code in chrome window but in the extension popup page the button doesn't do anything, why?

abraham
  • 41,605
  • 9
  • 84
  • 134
Andro
  • 3
  • 4

2 Answers2

1

Chrome extensions cannot use inline code. Instead, get the element in Javascript. See https://developer.chrome.com/extensions/contentSecurityPolicy

Daniel Herr
  • 14,666
  • 4
  • 39
  • 56
0

Please check this onClick within Chrome Extension not working

Chrome App Inline JavaScript will not be executed

I used to have this problem too, but I use Jquery, so far so good.

Community
  • 1
  • 1
wong ian
  • 123
  • 8
  • 2
    When encountering such situations, in most cases you should flag the question as duplicate and not create an answer that is just "This question answers this". – Xan May 19 '15 at 09:00