flash和跨域问题

发布于 2024-10-01 22:51:13 字数 793 浏览 6 评论 0原文

我正在运行一个rails3项目,其中包含所有javascript、图像、swfs等的外部资产主机。这是在一个完全不同的域上。所以知道我尝试使用 swfobject 嵌入一些 SWF。在开发中(同一主机)一切正常,但在生产中(不同主机)它不会启动闪存(firebug 显示文件已加载,但页面上没有显示任何内容)。我已经将此 crossdomain.xml 文件放入资产主机的根目录中,但它根本没有改变任何内容。

http://my.host/crossdomain.xml

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
  <allow-access-from domain="*" />
</cross-domain-policy>

http://my.host/swfs/sound1.swf http://my.host/swfs/video1.swf ...

我该怎么做才能让它发挥作用?我使用的 SWF 不是由我开发的,因此我无法更改它们。有些是简单的声音,有些是视频和小型“应用程序”。我不想让 Rails 为 swf 服务。

I'm running a rails3 project with an external asset host for all javascript, images, swfs etc. This is on a completely different domain. So know I tried to embed some SWFs using swfobject. In development (same host) everything works fine, but in production (different hosts) it doesn't start the flash (firebug shows the file is loaded but nothing appears on the page). I already put this crossdomain.xml file in the root of the asset host but it does not change anything at all.

http://my.host/crossdomain.xml

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
  <allow-access-from domain="*" />
</cross-domain-policy>

http://my.host/swfs/sound1.swf
http://my.host/swfs/video1.swf
...

What can I do to make it work? The SWFs I'm using are not developed by me, so I cannot change them. Some are simple sounds, others are videos and small "apps". I don't want to have to make rails serve the swfs.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

寂寞美少年 2024-10-08 22:51:13

在最近的 Flash 版本中不起作用,您必须指定确切的域和端口,例如:

<cross-domain-policy>
   <site-control permitted-cross-domain-policies="all"/>
   <allow-access-from domain="my.host" to-ports="80,8080"/>
</cross-domain-policy>

当然您应该放置跨域.xml 放入 Rails 应用程序公共目录的根目录中,而不是放在资产主机上。

<allow-access-from domain="*"/> doesn't work in recent Flash versions, you have to specify the exact domain and ports, e.g.:

<cross-domain-policy>
   <site-control permitted-cross-domain-policies="all"/>
   <allow-access-from domain="my.host" to-ports="80,8080"/>
</cross-domain-policy>

And surely you should put the crossdomain.xml into the root of your rails app public directory, not on your asset host.

酒儿 2024-10-08 22:51:13

您的“内容”主机需要允许来自“资产”主机的访问,而不是相反。

这是为了保护用户免受跨站点脚本攻击,因此让保存文件的主机决定他们是否可以访问将是倒退的。

Your "content" host needs to allow access from your "asset" host, not the other way around.

This is to protect users from cross site scripting, so having the host that holds the files decide whether or not they can have access would be all backwards.

我是有多爱你 2024-10-08 22:51:13

除了上面的答案(将 crossdomain.xml 放在请求主机上,而不是资产主机上)之外,我还必须将参数allowscriptaccess:“always”添加到swfobject。否则Flash中的ExternalInterface无法启动。

Additional to the above answer (put the crossdomain.xml on the requesting host, not the asset host) I had to add the param allowscriptaccess: "always" to swfobject. Otherwise the ExternalInterface in the flash could not be started.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文