[英]Embed SWF file in Firefox extension
I'm developing extensions for Chrome, Safari and Firefox, and I need to add SWF file in my extension. 我正在为Chrome,Safari和Firefox开发扩展程序,并且需要在扩展程序中添加SWF文件。 I want to show it on a page.
我想在页面上显示它。 I read in documentation that I can store media files in Chrome and Safari extension.
我阅读了有关可以在Chrome和Safari扩展程序中存储媒体文件的文档。
Can I do the same with Firefox? 我可以用Firefox做同样的事情吗?
Yes, a Firefox extension can also contain any files you like. 是的,Firefox扩展也可以包含您喜欢的任何文件。 But you probably meant to ask: "Can I get a URL of a file in my extension that will be usable on a web page?"
但是您可能想问:“我可以在扩展名中获取一个可在网页上使用的文件的URL吗?” If you are using the Add-on SDK then it is simply:
如果您使用的是附加SDK ,则只需:
var self = require("self");
var url = self.data.url("file.swf");
In a classic add-on it is slightly more complicated - chrome://
URLs normally cannot be used by web pages, for security reasons. 在经典附加组件中,它稍微复杂一些-出于安全原因,网页通常无法使用
chrome://
URL。 You can however specify the contentaccessible
flag for your namespace in chrome.manifest
, eg: 但是,您可以在
chrome.manifest
为命名空间指定contentaccessible
标志 ,例如:
content myextension chrome/content/ contentaccessible=yes
Then web pages will be able to use chrome://myextension/content/file.swf
. 然后,网页将能够使用
chrome://myextension/content/file.swf
。 The other option would be to register a resource://
namespace , these are always accessible from web pages. 另一种选择是注册一个
resource://
名称空间 ,这些名称始终可以从网页访问。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.