是否可以从Flash电影中打开JQuery灯箱?

时间:2009-06-17 10:43:30

标签: jquery flash

是否可以从Flash电影中打开JQuery灯箱?

2 个答案:

答案 0 :(得分:3)

尝试Calling any JS lightbox from Flash using jQuery

闪光:

import flash.external.ExternalInterface;
button.addEventListener(MouseEvent.CLICK, external, false, 0, true);
function external(evt:MouseEvent):void {
 ExternalInterface.call("external", "lightbox/photos/image1.jpg");
}

使用Javascript:

function external(path) { // pass in the correct path to the function so we only need one <A> for infinite amount of calls from  flash              
// if the lightbox does not exist we will make it               
 if ($('a#lightbox').length == 0) {                 
  $("body").append("</A><A id="lightbox" style="visibility: hidden; position: absolute; left: -9999px;" href="http://www.thetruetribe.com/+path+">calling js lightbox from flash</A>");                
  $('a#lightbox').lightBox();           
// if it already exists but the path is different we will set the new path              
 } else if ($('a#lightbox').attr("href") != path) {                 
  $('a#lightbox').attr("href", path);           
 }      
// now we will simulate the click here.             
 $('a#lightbox').trigger("click");      
}

或者你可以将flashLightBoxInjector Start Lightbox from Flash一个PrototypeJS类移植到jQuery框架而不会有太多麻烦,如果你对编写javascript有点自信

答案 1 :(得分:0)

是的,你可以做到。

要调用javascript函数doIt(),请编写:

getURL("javascript:doIt()");

但实际上,如果你必须这样做,可能有更好的方法来解决你的问题。

JRH