使用Javascript(jQuery)插入Flash时避免页面刷新

时间:2013-03-02 16:19:44

标签: javascript jquery flash

我有这个功能

function onVideo(vchat, idUser){
        $('#videollamada').html('<div class="videollamada">'+
                                '<div align="right">'+
                                    '<a href="javascript:closevll(0,'+idUser+');">Cerrar</a></div>'+
                                '<div align="center">');
        if (AC_FL_RunContent == 0) {
                    alert("This page requires AC_RunActiveContent.js.");
                } else {
                    AC_FL_RunContent(
                                     'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
                                     'width', '350',
                                     'height', '240',
                                     'src', 'videochat',
                                     'quality', 'high',
                                     'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
                                     'align', 'middle',
                                     'play', 'true',
                                     'loop', 'true',
                                     'scale', 'showall',
                                     'wmode', 'window',
                                     'devicefont', 'false',
                                     'id', 'videochat',
                                     'bgcolor', '#ffffff',
                                     'name', 'videochat',
                                     'menu', 'true',
                                     'allowFullScreen', 'true',
                                     'allowScriptAccess','sameDomain',
                                     'movie', '../../vChat/videochat?address=ec2-50-19-75-28.compute-1.amazonaws.com&from=0&to=1',
                                     'salign', ''
                                     ); //end AC code
                }
        $('#videollamada').append('</div></div>');

        usingvll= vchat;
        $('#vll_'+idUser).html('<img src="images/webcamUs.png" width="15" />&nbsp;<img src="images/phoneOut.png" width="15" />');
}

它应该为视频聊天提供可见空间。它本身可以工作,我可以加载任何HTML等。当我尝试在flash中添加一个小rtmp客户端时出现问题。它不是在页面中显示,而是刷新页面,而只是在浏览器中加载swf。

有人知道如何正确加载swf,而不是刷新浏览器吗?

修改

这就是AC_FL_RunContent的样子

function AC_FL_RunContent(){
    var ret =
    AC_GetArgs
    ( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
    , "application/x-shockwave-flash"
    );
    AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
} 

1 个答案:

答案 0 :(得分:1)

就像@ d1001001说的那样,使用swfobject代替AC_FL_RunContent就可以了,就像这样:

<script type="text/javascript" src="chat/js/swfobject.js"></script>
<script type="text/javascript>
function onVideo(vchat, idUser){

        $('#videollamada').html('<div class="videollamada">'+
                                '<div align="right">'+
                                    '<a href="javascript:closevll(0,'+idUser+');">Cerrar</a></div>'+
                                '<div id="swfclient" align="center"><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></div></div>');
        usingvll= vchat;
        $('#vll_'+idUser).html('<img src="images/webcamUs.png" width="15" />&nbsp;<img src="images/phoneOut.png" width="15" />');

        //SWFObject
        var flashvars = {};
        flashvars.address = "ec2-50-19-75-28.compute-1.amazonaws.com";
        flashvars.from = "from";
        flashvars.to = idUser;
        var params = {};
        params.quality = "high";
        params.bgcolor = "#cccccc";
        var attributes = {};
        attributes.align = "middle";
        swfobject.embedSWF("http://50.17.226.114/vChat/videochat.swf", "swfclient", "350", "240", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
}
</script>