請(qǐng)注意,這只是一個(gè)變通的方法,換湯不換藥,并未能最終解決存在的問(wèn)題,通過(guò)驗(yàn)證只是一種表象,這樣的思路是不是可取,在實(shí)際操作中請(qǐng)大家自行斟酌。
首先建立一個(gè)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腳本定義了一個(gè)函數(shù)swf,并設(shè)置三個(gè)變量,它們分別是:flile文件鏈接,w寬度,h高度。在xhtml中向這個(gè)函數(shù)傳遞變量即可實(shí)現(xiàn)flash的嵌入。如下代碼:
<div id="flash">
<script type="text/javascript" language="javascript">swf('VeVbcom.swf','500','220');</script>
</div>
建立id為flash的div作為一容器,在其內(nèi)部嵌入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標(biāo)準(zhǔn)的嵌入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(VeVbcom.swf','500','220');</script>
</div>
</body>
</html>
新聞熱點(diǎn)
疑難解答
圖片精選