开发者

Calling javascript via AS3 externalinterface within a colorbox

开发者 https://www.devze.com 2023-01-13 12:52 出处:网络
I have a swf that opens up inside a colorbox window. When the video finishes playing, I make an externalinterface call to a javascript function to close the colorbox.

I have a swf that opens up inside a colorbox window. When the video finishes playing, I make an externalinterface call to a javascript function to close the colorbox.

I'm trying to execute the following AS3 code:

ExternalInterface.call('parent.$.fn.colorbox.close()')

I can't seem to get this to work. 开发者_如何学CThe colorbox won't close.

I also tried this to see if I was just making the wrong function call, but this didn't work either: ExternalInterface.call('alert("hello world")')

However, if I browse to the url of the swf file, so that it doesn't open inside the colorbox, the alert() call works just fine.


Try this:

ExternalInterface.call('parent.$.fn.colorbox.close');

And this:

ExternalInterface.call('alert','hello world');

Alternatively, you could call eval and pass JS code as a String (you don't need this here, but it's handy in some cases).

ExternalInterface.call('eval','parent.$.fn.colorbox.close()')
0

精彩评论

暂无评论...
验证码 换一张
取 消