javascript调用flash文件的实例代码

发布时间:2020-01-21编辑:脚本学堂
本文介绍下,用javascript调用flash文件(swf)的例子,有需要的朋友参考下吧。

js代码调用flash文件,如下所示:
 

复制代码 代码示例:
<!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=utf-8" />
<title>用js来调用flash--www.jb200.com</title>
<script type="text/javascript">
function flashad(url,w,h,id){
    document.write("<object id='"+id+"' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0' width='"+w+"' height='"+h+"'><param name='movie' value='"+url+"'><param name='wmode' value='transparent'><param name='allowScriptAccess' value='always'><param name='allowFullScreen' value='false' /><param name='quality' value='high'><param name='menu' value='false'><embed width='"+w+"' height='"+h+"' src='"+url+"' name='"+id+"' allowScriptAccess='always' allowFullScreen='false' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' wmode='transparent' type='application/x-shockwave-flash'></embed></object>");
}
/*
    参数:url:flash的swf文件地址,可以是绝对路径也可以是相对路径
    w:flash宽度;
    h:flash高度;
    id:flash的id
*/
</script>
</head>
<body>
<!--引入flash-->
<SCRIPT>flashad("url/demo.swf",160,140,"myflash")</SCRIPT>
</body>
</html>

建议大家找个flash文件,调入此例中,亲自测试下。