MrCode
MrCode

Reputation: 64526

Javascript call from inside Flash, within a Facebook Canvas App

I have a Facebook Canvas iframe app. In that, I have a SWF object which needs to call a javascript function which is defined in my main facbebook app body. The call is not being made, I'm guessing Facebook are stopping it.

There must be a way around this?

I am doing a test call like this from Flash (AS2):

getURL("javascript:alert(1);");

Do I need to try and capture the facebook iframe and use that in Flash?

Upvotes: 0

Views: 774

Answers (3)

MrCode
MrCode

Reputation: 64526

I knew there was a way around this. Put the flash in a HTML document and set document.domain = x. In the body of the Canvas app, also set the same document.domain = x. Then use an iframe to show the flash's HTML document.

The flash then can make javascript calls and interact with your canvas app as needed.

Upvotes: 0

socksocket
socksocket

Reputation: 4371

you need to use ExternalInterface class:
ExternalInterface Documentation

it's easy as ABC. for example this line of code will execute
the alert javascript function.

ExternalInterface.call("javascript:alert();");

Upvotes: 1

Related Questions