actionscript calling javascript with Security Exception
I have a swf hosted at domain A, and I have a html at domain B
My swf is able to be loaded from accessing the html at domain B. However, the swf gets a
SecurityError: Error #2060: Security sandbox violation: ExternalInterface caller http://domainA.com/TrialApp.swf cannot access http://DomainB.com/.
The as3 is just the below:
ExternalInterface.call("javascript:_invite();");
I've also loaded the开发者_如何学Python crossdomain policy file from Domain B during initialization.
Security.loadPolicyFile( "http://DomainB/crossdomain.xml" );
How do I go about solving this?
in my html, I have
allowscriptaccess='always'
Thanks in Advance
Jacob is right, you are not supposed to include the javascript protocol when using ExternalInterface.call().
I am far from certain that it will solve the security exception, but you could try to do:
ExternalInterface.call("_invite");
... instead of:
ExternalInterface.call("javascript:_invite();");
The documented way to use ExternalInterface.call() is ExternalInterface.call(functionName:String, ... arguments). In practice, you can also send a string that is a piece of JavaScript (without "javascript:"), and it will be executed, so ExternalInterface.call("_invite();") could also work.
精彩评论