flash对象未在IE中正确嵌入

时间:2011-04-07 15:33:47

标签: javascript jquery html flash

我为jquery http://plugins.jquery.com/project/WebcamQRCode下载了这个小样本,它是一个网页插件,它显示了一个flash播放器,通过网络摄像头捕获qr代码。它显示了firefox和chrome中的flash播放器,但它没有在IE中显示。我在IE中有flash播放器,因为我在这个网页http://blog.jactionscripters.com/2009/05/23/introduction-of-qr-code-reader-library /中尝试了这个项目,它确实显示了qr代码。

一个人告诉我检查它是否是使用swfobject嵌入的,我检查了项目的.js文件并将其嵌入为swfobject,是否有人可以帮我确定问题所在?

这是jqery.webcamqrcode.js

中代码的一部分
  $.WebcamQRCode.start = function( $this ){
        var _flash = $('<object></object>');
        var _messageNoFlash = $('<p></p>');
        var __options = $this.data( 'webcam_qrcode_options' );

        // Set message if no flash
        _messageNoFlash.text( __options.messageNoFlash );

        // Set flash object information
        _flash.attr( 'type', "application/x-shockwave-flash" );
        _flash.attr( 'data', __options.path + "swf/webcamqrcode.swf?ID=" + $this.attr( '_webcam_qrcode_id' ) );
        _flash.attr( 'width', "100%" );
        _flash.attr( 'height', "100%" );
        _flash.append( _messageNoFlash );

        $this.html( _flash );
    }

谢谢!

2 个答案:

答案 0 :(得分:0)

IE需要<param name="movie" value="blah.swf">,您应该将其附加到_flash

您甚至可以附加<embed>版本。

在此处了解如何构建兼容多浏览器的Flash对象: http://www.alistapart.com/articles/flashsatay

或者,更简单,您可以使用SWFObject: http://code.google.com/p/swfobject/

答案 1 :(得分:0)

使用SWFObject嵌入Flash。绝对没有理由不这样做。您甚至不必自己托管脚本,Google会为您执行此操作:http://code.google.com/p/swfobject/wiki/hosted_library

示例:

<html>
  <head>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
    <script type="text/javascript">
    var flashvars = {"ID": WEBCAM_QRCODE_ID}; // fill in this value
    var params = {};
    var attributes = {};
    swfobject.embedSWF("path/to/webcamqrcode.swf", "flash", "100%", "100%", "9.0.0", null, flashvars, params, attributes);
    </script>
  </head>
  <body>
    <div id="flash"></div>
  </body>
</html>