当我使用jquery生成页面时(通过在html页面中包含startup.js),我无法通过flex访问cookie。
startup.js
function init_element() {
$(document).ready(function(event){
$("#accountBarDiv").css("position", "absolute");
$("#accountBarDiv").css("left", "0px");
$("#accountBarDiv").css("background-color", "transparent");
$("#accountBarDiv").append("<iframe id=\"ifrId\" style=\"width:10px;height:10px\"></iframe>");
$("#accountBarDiv").append("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\" width=\"230px\" height=\"70px\" id=\"ogra2\"> <param name=\"movie\" value=\"http://localhost/ogra/bin/ogra.swf\"/> <param name=\"allowscriptaccess\" value=\"always\"/> <param name=\"wmode\" value=\"transparent\"/> <embed src=\"http://localhost/ogra/bin/ogra.swf\" quality=high width=\"230px\" height=\"70px\" name=\"ogra2\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"> </embed></object>");
});} init_element();
我还包括了一个script.js。它包含一个函数test(),这将返回“hello”。
我ogra.swf我调用一个返回ExternalInterface.call来进行函数测试,我的答案不幸地为空。
当我用html和body更改我的startup.js和对象并嵌入时(由于所有引号很难在这里发布)而且我只是document.write str。我可以完美地访问我的cookie。
太糟糕了,他们命令我在jquery中编写startup.js。
有没有人知道为什么我无法在我的flex应用程序中访问我的cookie?
当然,jquery的东西在FF中工作,而不是在IE中。
答案 0 :(得分:0)
AFAIK Flash应用程序不发送cookie。这是Flash的一个已知限制,因为NPAPI二进制文件直接自行建立连接,而无需通过浏览器。
这被称为“Flash Cookie Bug”,列于例如SWFUpload的已知问题。 http://demo.swfupload.org/Documentation/#knownissues
您可以尝试一些解决方法,例如:使用Javascript解析document.cookie
并使用flashvars
将会话cookie注入Flash,然后通过POST / GET发送会话cookie。
一个名为“Cookies”的SWFUpload插件做同样的事情。 http://demo.swfupload.org/Documentation/#plugins