如何在chrome扩展中嵌入站点

时间:2022-02-27 20:46:22

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.

你好,我正在尝试做一个谷歌chrome扩展,它将会在浏览器上有一个按钮,当点击它时,将会打开一个弹出窗口,显示这个网站http://www.visualbounds.com/Private/XboxMB/Chatbox/。但我是新手,当我尝试使用iframe时,弹出框中什么都没有。

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

我想问的是如何在弹出窗口中嵌入网站?

Heres the manifest.json if it helps.

这是清单。如果它有助于json。

{
  "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

这是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

肖恩

1 个解决方案

#1


1  

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

首先,需要在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元素

<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.

您将在弹出窗口中看到嵌入的iframe。

如何在chrome扩展中嵌入站点

#1


1  

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

首先,需要在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元素

<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.

您将在弹出窗口中看到嵌入的iframe。

如何在chrome扩展中嵌入站点