javascript - jQuery 听起来 IE7/IE8 与 FlashExternalInterface 存在问题

标签 javascript jquery flash audio externalinterface

我想向网络应用程序添加声音警报。我相信 Flash 是支持所有主要浏览器的最佳方式。 IE、火狐、Chrome、Safari。 Chrome 似乎无法使用非 Flash 声音解决方案。

我一直在使用 jQuery,并且想使用 jQuery Sound插入。 jQuery Sound Plug-in Demo 显示了一个示例。 ,但是我无法在 IE7 和 IE8 Beta 中使用此功能。

我在下面的代码部分中遇到了 JavaScript 问题。

load: function(evt, url) {
    var self = $(this);
    var id = self.data("sound.settings").id;
    var movie = self.data("sound.get_movie")(id);
    movie.load(url);
    self.data("sound.isPlaying", true);
},

该插件还使用以下函数来获取在 IE 浏览器上看起来不错的 Flash 影片。

var get_movie = function(id) {
    var movie = null;
    if ($.browser.msie) {
        movie = window[id];
    } else {
        movie = document[id];
    }
    return movie;
};

我是否缺少一些东西,因此它可以在 IE7 和 IE8 Beta 中工作?任何帮助将不胜感激。

最佳答案

更改以下代码后问题得到解决:

    if ($.browser.msie) {
        var html = '<object id="' + settings.id + '" data="' + settings.swf + '" type="application/x-shockwave-flash" width="0" height="0">';
        html += ' <param name="movie" value="' + settings.swf + '"/>';
        html += ' <param name="AllowScriptAccess" value="always"/>';
        html += ' <param name="quality" value="high"/>';
        html += ' <param name="wmode" value="transparent"/>';
        html += ' <!-- -->';
        html += ' </object>';
    } else {
        var html = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
        html += ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" width="0" height="0"';
        html += ' id="' + settings.id + '"';
        html += ' align="middle">';
        html += '<param name="movie" value="' + settings.swf + '" />';
        html += '<param name="quality" value="' + settings.quality + '" />';
        html += '<param name="FlashVars" value="id=' + settings.id + '"/>';
        html += '<param name="allowScriptAccess" value="always"/>';
        html += '<embed src="' + settings.swf + '" FlashVars="id='+ settings.id +'"';
        html += ' allowScriptAccess="always" quality="' + settings.quality + '" bgcolor="#ffffff" width="0" height="0"';
        html += ' name="' + settings.id + '" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
        html += '</object>';
    }

...


var get_movie = function(id) {
    var movie = null;
    if ($.browser.msie) {
        //movie = window[id];
        movie = document.getElementById(id);
    } else {
        movie = document[id];
    }
    return movie;
};

引用来源:SoundManager 2

关于javascript - jQuery 听起来 IE7/IE8 与 FlashExternalInterface 存在问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/464568/

相关文章:

javascript - ReactJS - 如何在 map 函数中设置状态

flash - 在 AS3 中加载嵌入图像

flash - AS3 KeyboardEvents 在我点击屏幕按钮后才会触发

flash - "empty"crossdomain.xml 强制执行什么策略?

javascript - colorbox jquery lightbox 随父窗口滚动

javascript - 在 contenteditable div 中突出显示的文本周围添加 html 标签

javascript - 根据div高度排列控件

javascript - 混淆使用 v-bind :class ternary on a v-for element when referencing the properties of the v-for element

javascript - Sequelize 查询符合 $LIKE 的要求,但收到 ER_PARSE_ERROR

javascript - twitter-typeahead 不适用于 Bloodhound