2010-12-10 75 views
1

調用在Flash彈出窗口的JavaScript函數,我調用使用AS3 ExternaInterface:呼叫在由Flash

ExternalInterface.call("window.open","http://www.mypage.com,"win","height=640,width=480,toolbar=no,scrollbars=yes"); 

在調用彈出一個彈出窗口,有一個javascript函數我想訪問。如果javascript與電影位於同一頁面,我可以使用

ExternalInterface.call("jsFunction", "value") 

因爲不是,我怎樣才能在彈出窗口中訪問javascript函數?

回答

3

您需要存儲對您打開的窗口的引用才能訪問它。如果你控制的HTML /主力主攻的JavaScript中,你可以插入這樣的事情到<script>塊:

var popupref; 

和窗口開啓功能:

function openWindow() { 
    popupref = window.open(/*your params here*/) 
} 

,然後在你的ExternalInterface打開你的窗口

ExternalInterface.call("openWindow"); 

,並打電話給你的彈出窗口

ExternalInterface.call("popupref.myfunc"); 

我不知道我的頭頂,但你可能可以通過嵌入整個popupref = window.open(...)調用來製作ExternalInterface.call(...)

請注意,您打開的窗口必須來自同一個域和端口,否則跨域瀏覽器安全將不會讓您撥打電話。

+0

傳遞「window.open」到ExternalInterface.call()的作品,但我將無法將我自己的數據傳遞給彈出 – Dave 2010-12-10 06:34:09