Flash/Javascript communication error
I'm using the following code. It works fine with getElementByID but if I use a OS detection function it stops working.
function getFlashMovie(movieName)
{
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}
getFlashMovie('myId').sendToActionsript(str);
The above code does not work whereas the line below is working any Ideas?
document.getElementById('myId').sendToActionscript(str);
EDIT: Another piece of code for the same thing, which isn't working either.
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);
}
}
This seems to work
function thisMovie(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName];
} else {
return document[movieName];
}
}
精彩评论