0
我正在使用以下代碼。它使用getElementByID可以正常工作,但如果使用OS檢測功能,它將停止工作。Flash/Javascript通信錯誤
function getFlashMovie(movieName)
{
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}
getFlashMovie('myId').sendToActionsript(str);
上面的代碼不起作用,而下面的代碼行是任何想法?
document.getElementById('myId').sendToActionscript(str);
編輯:另一塊代碼爲同樣的事情,這是不工作。
function getFlashMovieSecond(movieName)
{
if (window.document[movieName])
{
return window.document[movieName];
}
if (navigator.appName.indexOf("Microsoft Internet")==-1)
{
if (document.embeds && document.embeds[movieName])
return document.embeds[movieName];
}
else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
{
return document.getElementById(movieName);
}
}
嘗試使用自帶的幫助(例子http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/external /ExternalInterface.html#includeExamplesSummary) - 逐漸剝離不需要的位,並將代碼合併到項目中。需要記住的是,有些瀏覽器使用嵌入標籤獲取Flash內容,而其他瀏覽器則使用object標籤,因此請確保在兩個標籤上都有相同的名稱/標識,並且AllowScriptAccess也設置爲「始終」。 HTH – 2010-04-15 14:06:10