Function not invoke in the Javascript file in Chrome extension -


functions of background.js file not invoked onclick() method in popup.html. there wrong manifest.jjson file? because funtion work properly.

manifest.json

{         "name": "popping alert",         "description": "http://stackoverflow.com/questions/15194198/background-js-not-working-chrome-extension",         "background": {             "scripts": [                 "background.js"             ]         },         "content_scripts": [         {           "matches": ["http://www.google.com/*"],           "css": ["print.css","styles.css"],           "js": ["background.js"]         }       ],         "version": "1",         "manifest_version": 2,         "browser_action": {             "default_title": "click me",             "default_icon": "hello.png"         }     } 

popup.html

<script type="text/javascript" src="background.js"></script>  <section id="content">                 <ul class="column">                     <!--eqblock-->                     <li>                         <section class="block">                                     <a href="#"><img src="images/facebook.jpg" alt=""  /></a>                                          <h2><a href="#" onclick="myfunction1()">facebook </a> </h2>                            </section>                     </li>         </ul>         </section> 

background.js

function myfunction1 () {                                  localstorage.setitem("facebook", "https://www.facebook.com/");                                 window.open(localstorage.getitem("facebook"));                                 alert("ok");                                         } 

you can't call functions background.js non-background scripts directly. contexts different. need use message passing


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -