爱心论坛互帮互助平面设计 网页设计 → [转帖]符合web标准的嵌入Flash的方法

分享到:

  共有7759人关注过本帖树形打印复制链接

主题:[转帖]符合web标准的嵌入Flash的方法

帅哥哟,离线,有人找我吗?
紫枫
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 等级:论坛版主 帖子:470 精华:1 积分:4685 金钱:10304 金币:0 魅力:2698 威望:0 登陆:90 注册:2006/8/1 13:01:29 近访:2008/9/12 13:39:10 在线:在线0天0小时0分钟.
离升级差0天20小时0分钟.
目前等级0
[转帖]符合web标准的嵌入Flash的方法  发帖心情 Post By:2008/2/26 15:12:18 [只看该作者]

贴子已被锁定

常有网友提问,如何让网页中嵌入的Flash标签也符合web标准。目前还没有一个完美的解决办法,这篇文章中,我们将Flash嵌入标签写入js文件中,通过变量传递参数的办法来回避不符合标准的标签。
 


  请注意,这只是一个变通的方法,换汤不换药,并未能最终解决存在的问题,通过验证只是一种表象,这样的思路是不是可取,在实际操作中请大家自行斟酌。

  首先建立一个JS文件flash.js。写入如下代码: 网页教学网

function swf(file,w,h) {
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+w+'" height="'+h+'"> ');
    document.write('<param name="movie" value="' + file + '">');
    document.write('<param name="quality" value="high"> ');
    document.write('<param name="wmode" value="transparent"> ');
    document.write('<param name="menu" value="false"> ');

    document.write('<embed src="' + file + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'"></embed> ');
    document.write('</object> ');
}


  上面的js脚本定义了一个函数swf,并设置三个变量,它们分别是:flile文件链接,w宽度,h高度。在XHTML中向这个函数传递变量即可实现flash的嵌入。如下代码:

<div id="flash">
    <script type="text/javascript" language="javascript">swf('webjxcom.swf','500','220');</script>
</div>

  建立id为flash的div作为一容器,在其内部嵌入js脚本,变量依次为:文件路径、宽度、高度。 网页教学网

  看下面的全部代码:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>符合web标准的嵌入Flash的方法</title>
<script type="text/javascript" language="javascript" src="flash.js"></script>
<style type="text/css">
#flash { width:500px; margin:50px auto; border:5px solid #03c;}
</style>
</head>
<body>
<div id="flash">
    <script type="text/javascript" language="javascript">swf(webjxcom.swf','500','220');</script>
</div>
</body>
</html>



我很喜欢你!!!!!!!!
 回到顶部