日期:2014-05-16  浏览次数:20359 次

JS如何得到SWF的宽度
图片加载获得其宽度好象可以这样实现
var   imgPreloader   =   new   Image();

imgPreloader.onload   =   function(){
      var   imageWidth   =   imgPreloader.width;
      var   imageHeight   =   imgPreloader.height;
}

能否用此方法获得SWF的宽度?

------解决方案--------------------
可以的,比如:

<HTML>
<HEAD>
<meta http-equiv=Content-Type content= "text/html; charset=GB2312 ">
<TITLE> 未命名-1 </TITLE>
</HEAD>
<BODY bgcolor= "#FFFFFF ">
<!-- URL 's used in the movie-->
<!-- text used in the movie-->
<OBJECT classid= "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 "
codebase= "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0 "
WIDTH= "550 " HEIGHT= "400 " id= "未命名-1 " ALIGN= " ">
<PARAM NAME=movie VALUE= "未命名-1.swf "> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src= "未命名-1.swf " quality=high bgcolor=#FFFFFF WIDTH= "550 " HEIGHT= "400 " NAME= "未命名-1 " ALIGN= " "
TYPE= "application/x-shockwave-flash " PLUGINSPAGE= "http://www.macromedia.com/go/getflashplayer "> </EMBED>
</OBJECT>

<SCRIPT>
//////////////////////////////////////////////////////////////
var swf = document.getElementById( "未命名-1 ");
alert(swf.width);
alert(swf.height);
//////////////////////////////////////////////////////////////
</SCRIPT>

</BODY>
</HTML>

代码IE测试通过了
------解决方案--------------------
<object id= "wc " classid= "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 " codebase= "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0 ">
<param name= "movie " value= "Banner/200610380478457.swf " />
<param name= "quality " value= "high " />
<embed src= "Banner/200610380478457.swf " quality= "high " pluginspage= "http://www.macromedia.com/go/getflashplayer " type= "application/x-shockwave-flash "> </embed>
</object>
<script type= "text/javascript ">
window.onload = function () {
var wc = document.getElementById( "wc ");
alert(wc.offsetWidth);
alert(wc.offsetHeight);
};
</script>
你不设置高它是不会显示实际尺寸的。