【问题标题】:How can i embed a site in a chrome extension pop up如何在 chrome 扩展弹出窗口中嵌入网站
【发布时间】:2013-10-26 18:55:32
【问题描述】:

您好,我正在尝试制作一个 Google chrome 扩展程序,该扩展程序将在浏览器上具有一个按钮,单击该按钮时将打开一个带有此站点 http://www.visualbounds.com/Private/XboxMB/Chatbox/ 的气泡弹出窗口。但是我是新手,当我尝试使用 iframe 时,弹出窗口中没有任何内容。

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

如果有帮助,这里是 manifest.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"
    ]
  }

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

任何帮助将不胜感激。

亲切的问候

-肖恩

【问题讨论】:

    标签: javascript html json google-chrome google-chrome-extension


    【解决方案1】:

    首先你需要在 manifest.json 中指定默认的弹出目标

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

    然后插入一个 iframe 元素

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

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

    【讨论】:

    • 您能解释一下与 OP 所做的不同之处吗?您的代码似乎几乎相同..
    猜你喜欢
    • 2015-06-22
    • 2011-09-27
    • 1970-01-01
    • 1970-01-01
    • 2015-09-19
    • 1970-01-01
    • 2016-12-30
    • 2012-03-08
    • 1970-01-01
    相关资源
    最近更新 更多