swfobject.js 简介
swfobject是什么? SWFObject是一个用于在HTML中方便插入Adobe Flash媒体资源(*.swf文件)的JavaScript模块。它能够避免您的 HTML、XHTML中出现object、embed等非标准标签,从而符合更加标准。 如果你现在需要急于了解如何使用它,那么你可以看看我下面的简短的介绍,相信能够帮助到您。 第一步,你可以去到http://code.google.com/p/swfobject/downloads/detail?name=swfobject_2_2.zip下载到它。 第二步,学会如何使用。 swfobject就是为我们提供更好更简单的方法将swf嵌入到html中,它给出两种方法让我们去做这事。 方法一:静态的插入 1. 使用object的标签插入swf 2. 在html的head内加入我们下载下来swfobject.js:?<scripttype="text/javascript"src="swfobject.js"></script> 3. 使用swfobject提供的接口来关联swf <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>SWFObject - step 3</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript" src="swfobject.js"></script> <script type="text/javascript"> swfobject.registerObject("myId","9.0.115","expressInstall.swf"); </script> </head> <body> <div> <object id="myId" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="780" height="420"> <param name="movie" value="test.swf" /> <!--[if !IE]>--> <object type="application/x-shockwave-flash" data="test.swf" width="780" height="420"> <!--<![endif]--> <p>Alternative content</p> <!--[if !IE]>--> </object> <!--<![endif]--> </object> </div> </body> </html>
<div id="myContent"> <p>Alternative content</p></div>
2. 在html的head内加入我们下载下来swfobject.js:?<scripttype="text/javascript"src="swfobject.js"></script> 3.?使用swfobject提供的接口来关联swf <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>SWFObject dynamic embed - step 3</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript" src="swfobject.js"></script> <script type="text/javascript"> swfobject.embedSWF("myContent.swf","myContent","300","120","9.0.0"); </script> </head> <body> <div id="myContent"> <p>Alternative content</p> </div> </body> </html>
var flashvars ={}; var params ={}; var attributes ={}; swfobject.embedSWF("myContent.swf","myContent","300","120","9.0.0","expressInstall.swf", flashvars, params, attributes); 这些我们都可以在需要的时候添加。 希望能够为所需要的朋友提供一点帮助。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |