SWFObject基本用法实例分析

本文实例讲述了SWFObject基本用法。分享给大家供大家参考。具体分析如下:

SWFObject是一个用于在HTML中方面插入Adobe Flash媒体资源(*.swf文件)的独立、敏捷的JavaScript模块。该模块中的JavaScript脚本能够自动检测PC、Mac机器上各种 主流浏览器对Flash插件的支持情况。它使得插入Flash媒体资源尽量简捷、安全。而且它是非常符合搜索引擎优化的原则的。此外,它能够避免您的 HTML、XHTML中出现object、embed等非标准标签,从而符合更加标准。

基本使用:

<!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>

参数定义:

<script type="text/javascript">
var flashvars = {
 name1: "hello",
 name2: "world",
 name3: "foobar"
};
var params = {
 menu: "false"
};
var attributes = {
 id: "myDynamicContent",
 name: "myDynamicContent"
};
swfobject.embedSWF("myContent.swf", "myContent", "300", "120", 
  "9.0.0","expressInstall.swf", flashvars, params, attributes);
</script>

参数定义2:

<script type="text/javascript">
var flashvars = false;
var params = {};
var attributes = {
 id: "myDynamicContent",
 name: "myDynamicContent"
};
swfobject.embedSWF("myContent.swf", "myContent", "300", "120", 
  "9.0.0","expressInstall.swf", flashvars, params, attributes);
</script>

希望本文所述对大家的javascript程序设计有所帮助。

相关推荐