开发者

Flash/Javascript communication error

开发者 https://www.devze.com 2022-12-26 18:33 出处:网络
I\'m using the following code. It works fine with getElementByID but if I use a OS detection function it stops working.

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];

    }

}

0

精彩评论

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