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

发布于 2024-07-13 07:33:36 字数 966 浏览 5 评论 0原文

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

我一直在使用 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 中工作? 任何帮助将不胜感激。

I would like to add sound alerts to a web application. I believe that Flash is the best way to do this to support all major browsers, ie. IE, Firefox, Chrome, Safari. Chrome does not seem to work with the non-flash sound solutions.

I have been using jQuery and would like to use the jQuery Sound plug-in. An example is shown at jQuery Sound Plug-in Demo, however I can not get this working in IE7 and IE8 Beta.

I am getting a JavaScript issue within the section of code below.

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);
},

The plug-in is also using the following function to get the Flash movie which looks fine for IE browsers.

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

Is there something I am missing here so this can work in IE7 and IE8 Beta? Any help would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

帅气称霸 2024-07-20 07:33:36

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

    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

The issue is fixed when the following code is changed:

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

Source Referenced: SoundManager 2

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文