Search code examples
javascripthtmljsongoogle-chromegoogle-chrome-extension

How can i embed a site in a chrome extension pop up


Hi I'm trying to make a Google chrome extension that will have a button on the browser, that when clicked will open up a bubble popup with this site http://www.visualbounds.com/Private/XboxMB/Chatbox/ . But I'm new this and when I try and use an iframe there is nothing in the popup.

So I guess I'm asking how can I embed the site in the pop up ?

Heres the manifest.json if it helps.

{
  "browser_action": {
    "default_icon": "Images/16.png",
    "default_popup": "popup.html"
  },
   "background": {
      "persistent": false,
      "scripts": [ "background.js" ]
   },
   "content_scripts": [ {
      "js": [ "jquery.js", "script.js" ],
      "matches": [ "https://www.xboxmb.com/*" ],
      "run_at": "document_start"
   },{ "matches": ["http://*/*", "https://*/*" ],
      "all_frames": true,
      "js": ["content.js"]
    }
    ],
   "description": "Chat intergration for XboxMB",
   "icons": {
      "16": "Images/16.png",
      "48": "Images/48.png"
   },
   "manifest_version": 2,
   "name": "XboxMB Chatbox",
   "options_page": "options.html",
   "version": "2.2",
   "permissions": [
        "http://www.visualbounds.com/Private/XboxMB/Chatbox/mobile.html"
    ]
  }

And here's the popup.html

<!doctype html>
<html>
<head>
    <style type="text/css">
    body {width:200; height:300;}
    </style>
</head>
<body>
    <iframe src="http://www.visualbounds.com/Private/XboxMB/Chatbox/mobile.html" width="100%" height="100%" frameborder="0">
    </iframe>
</body>
</html>

Any help would be much appreciated.

Kind Regards

-Sean


Solution

  • First you need to assign the default popup target in manifest.json

    {
      "manifest_version": 2,
    
      "name": "xbox",
      "description": "xbox description",
      "version": "2.2",
      "browser_action": {
        "default_popup": "main.html"
       }
    }
    

    And just insert an iframe element

    <iframe src="http://www.visualbounds.com/Private/XboxMB/Chatbox/mobile.html" width="320" height="480"></iframe>
    

    You will see the embedded iframe in the popup window.

    enter image description here