全部: 我用HTML创建了一个DIV,并在DIV中嵌入了一个flash。下面是HTML:
<head>
...
<script src="Scripts/swfobject_modified.js" type="text/javascript"> </script>
<script src="Scripts/GHAnimateObjectMove.js" type="text/javascript"> </script>
<style type="text/css">
.GHLogoAniFlashDiv {
margin: auto auto auto auto;
height: 302px;
width: auto;
left: 0px;
top: 0px;
overflow:hidden;
}
.FlashID {
margin: auto auto auto auto;
height: 302px;
width: 402px;
left: auto;
top: auto;
overflow:hidden;
}
</style>
</head>
<body>
<!-- align="center" align="absmiddle" align="center" -->
<div id="GHLogoAniFlashDiv" >
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="402" height="302" class="FlashID" id="FlashID" title="GHLogoAniFlash">
<param name="movie" value="Animate/GHLogoAniFlash.swf" />
<param name="quality" value="high" />
<param name="wmode" value="transparent" />
<param name="swfversion" value="6.0.65.0" />
<param name="expressinstall" value="Scripts/expressInstall.swf" />
<param name="SCALE" value="noscale" />
<embed src="Animate/GHLogoAniFlash.swf" quality="high"
width="402" height="302" name="movie"
play="true"
loop="ture"
quality="high"
allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer">
</embed>
<!-- No IE -->
<!--[if !IE]> align="absmiddle"-->
<object data="Animate/GHLogoAniFlash.swf" type="application/x-shockwave-flash" width="402" height="302" >
<!--[end if]-->
<param name="quality" value="high" />
<param name="wmode" value="transparent" />
<param name="swfversion" value="6.0.65.0" />
<param name="expressinstall" value="Scripts/expressInstall.swf" />
<param name="SCALE" value="noscale" />
<!-- Version of Flash Player <6.0 -->
<div>
<h4>Need Latest Adobe Flash Player。</h4>
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash Player" width="112" height="33" /></a></p>
</div>
<!--[if !IE]>-->
</object>
<!--<![end if]-->
</object>
</div>
...
然后我在“GHAnimateObjectMove.js”中使用javascript将flash移动到浏览器的一个位置:
function SetGHLogoDivLocation()//Set Logo DIV location;
{
var leftoffset=0;
var rightoffset=0;
LogoDivObj=document.getElementById("GHLogoAniFlashDiv");
FlashObj=document.getElementById("FlashID");
try{
findDimensions();
leftoffset=parseInt(600);
rightoffset=parseInt(300);
LogoDivObj.style.postion="relative";
if(LogoDivObj && FlashObj)
{
LogoDivObj.style.left=leftoffset+"px";
LogoDivObj.style.top=rightoffset+"px";
FlashObj.style.left=LogoDivObj.style.left;
FlashObj.style.top=LogoDivObj.style.top;
}
}
catch(err){
window.alert(err.message);
}
}
...
window.onresize=function (){SetGHLogoDivLocation();};
window.onload=function () {SetGHLogoDivLocation()};
但似乎无法将闪光移动到新位置(600px,300px)。它仍然留在页面的左侧。为什么?谁知道呢? 我在IE 9 win7上测试。我在eclipse中调试。我看到LogoDivObj.style.left,LogoDivObj.style.top,FlashObj.style.left和FlashObj.style.top已被更改。但是为什么flash无法移动到新的位置?