我引用这篇文章:
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/