javascript - 可以将外部 iframe 包含到 google chrome 扩展中吗

标签 javascript google-chrome iframe google-chrome-extension

我引用这篇文章:

http://julip.co/2010/01/how-to-build-a-chrome-extension-part-3-loading-any-web-page-in-a-popup/

<html>
<head>
    <style type="text/css">
    body {width:200; height:300;}
    </style>
</head>
<body>
    <iframe src="http://m.bing.com" width="100%" height="100%" frameborder="0">
    </iframe>
</body>
</html>

此扩展的源代码是:http://mfi.re/?imwxngtdkhg

但是它不显示任何内容。

我的问题是:外部 iframe 可以包含在 google chrome 扩展中吗?

最佳答案

是的,您可以在弹出窗口内显示iframe。它有点重,我不建议这样做,但你可以。

您链接的扩展程序的问题是 manifest.json 文件格式错误:

  • 缺少“manifest_version”参数,应将其设置为2
  • 浏览器操作的默认弹出窗口是使用 "default_popup" 定义的,而您使用的是 "popup",这是错误的。

这是正确的 manifest.json 文件:

{
    "manifest_version": 2,

    "name": "Mini Bing Search",
    "description": "Search Bing right from your browser without leaving your current page.",
    "version": "0.1",
    "browser_action": {
        "default_icon": "icon19.png",
        "default_popup": "popup.html"
    },
    "icons": { 
        "48": "icon48.png",
        "128": "icon128.png" 
    }
}

下载工作示例 HERE

关于javascript - 可以将外部 iframe 包含到 google chrome 扩展中吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26423899/

相关文章:

jquery - 检测 FB 嵌入后 iframe 上的点击

javascript - 防止 Iframe 点击输入 url Javascript

jquery - 在灯箱暂停按钮后重新加载多个 iframe 并导致所有 iframe 仅显示一个视频

javascript - Jquery 跳到最后一个 XML 子级

javascript - 是否可以向 Chrome 中现有的 websocket 连接发送消息?

google-chrome - chrome 检查器中的内容脚本是什么

javascript - getComputedStyle 文本修饰继承

javascript - 如何通过CasperJS从具有特定类的元素中获取href?

javascript - MATLAB 作为带有 Javascript 的 COM 自动化服务器

javascript - 如何使用 createElement 渲染函数在 javascript 中编写 vue.sync