javascript - How to code a Chrome Extension where any image from the project folder can be generated -


i'm working on project chrome extension image generate. how code chrome extension image project folder can generated? code far:

//popup.js    var images = ["img/1.jpg", "img/2.jpg", "img/3.jpg", "img/4.jpg", "img/5.jpg", "img/6.jpg"];    var randomname = images[math.floor(math.random() * images.length)];    document.getelementbyid("randomimage").style.backgroundimage = "url('/images" + randomname + "')";
<!--popup.html-->    <!doctype html>  <html>  <head><title>47</title></head>  <body>      <div id="randomimage"/>        </body>      <script type="text/javascript" src="jquery-3.2.1.min.js"></script>      <script src="popup.js"></script>  </html>

and manifest.json file:

    {     "name" : "47",     "description" : "爸爸,生日快乐!",     "manifest_version": 2,     "version" : "2.0",     "background": {     "scripts": "popup.js"   },     "background": {     "page": "background.html"   },      "browser_action" : {         "default_popup" : "popup.html",         "default_icon" : "img/icon.png"     } } 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -