开发者

Best way to embed Flash for modern browsers using HTML5?

This is such a common thing that I imagine there must be a "good" way of cleanly embedding Flash into HTML5? I'm only interested in supporting the following br开发者_如何学JAVAowsers: FF3, FF4, IE7, IE8, IE9, Chrome and Safari.

I know there's some Javascript solutions like SWFObject, but that seems like overkill. Isn't there just a clean, quick and easy way using HTML?

Additionally: Is there any downside to just using <embed>? It was previously depreciated by the W3C, but I understand it's back in HTML5. So why not just use it instead of faffing around with <object>?


Tried jQuery Tools?

Basically, all you got to do is:

<div id="clock"></div>

<script>
flashembed("clock", "/media/swf/global/clock.swf");
</script>

A working example would be:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script>

<div id="clock"></div>

<script>
flashembed("clock", "http://jquerytools.org/media/swf/global/clock.swf");
</script>

It worked with jQuery 2.0.3, 1.10.2, 1.9.0.


SWFObject was created to dynamically deal with the varying ways each browser interpreted the object tag. I am unaware of any real changes to this scenario, even with ie9, which still requires a user activation of an active-x object.

I still prefer SWFObject for its robust and straightforward handing of flash vars:

var flashvars   = {
    filePath:   "somePath",
    verbose:    "true"
};

var params  = {
    quality:    "high",
    wmode:  "opaque",
    menu:   "false",
    base:   "/flash/home_page/"
};

var attributes  = {
    id:     "flashContent"
};


    swfobject.embedSWF(
        "../flash/home_page/home.swf",
        "flashContent",
        "570",
        "325",
        "10.0.0",
        "../frameworks/swfobject/expressInstall.swf",
        flashvars,
        params,
        attributes,
        outputStatus
        );

I agree, it would be "nice" if there was an "even more" lightweight alternative, but the convenience makes up for whatever extra loads are required, imo.

cheers

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜