Silverlight与Flash在FF中的一些注意点

在HTML中,Silverlight、Flash以object标签的形式显示,如以下代码:
View Code
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" >
</object>

但是必须同时指定该object元素的height、width的值,否则在FF下不能显示。

同时如果height的值为百分比,则它的外围元素必须有高度,否则也不显示(width的值为百分比的情况也一样)

如下代码在FF下不能显示:

View Code
<div style="width:200px;">
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" style=" height:100%;width:100%">
</object>
</div>

如下代码在FF下可以显示(因为div默认宽度就是整个屏幕的宽度):

View Code
<div style="height:200px;">
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" style=" height:100%;width:100%">
</object>
</div>

另一个注意点也是在FF下,当把object元素用style.display=”none”的形式隐藏掉,再用style.display=””显示出来的时候,Silverlight、

Flash会重新加载,之前代码中的一些属性字段也都没了。(隐藏掉外围元素也是一样,即object外面有个div,隐藏div再显示一样触发重新加载)

另外,改变该object元素的style.position值,几乎都会让Silverlight、Flash重新加载,比如从static到absolute,从static到relative,

absolute到relative等等。将该object元素移动到别的DOM对象下面也会触发重新加载,比如document.body.appendChild(obj)。

以Silverlight为例:

Silverlight的App代码中,在Application启动的时候,弹出一个提示框:
View Code
private void Application_Startup(object sender, StartupEventArgs e)
{
this.RootVisual = new MainPage();
MessageBox.Show(
"启动”);
}

页面代码:

复制代码
View Code
<object id="obj" data="data:application/x-silverlight-2," type="application/x-silverlight-2" style=" height:110px;width:110px;">
<param name="source" value="ClientBin/Test.xap"/>
<param name="background" value="white" />
<param name="minRuntimeVersion" value="3.0" />
<param name="autoUpgrade" value="true" />
</object>
<br /><br /><br /><br /><br /><br /><br /><br />
<input type="button" value="隐藏?" onclick="obj.style.display='none'"/>
<input type="button" value="显示" onclick="obj.style.display='block'"/>
<br /><br />
<select id="Select1" value="inherit">
<option value="inherit">inherit</option>
<option value="absolute">absolute</option>
<option value="fixed">fixed</option>
<option value="relative">relative</option>
<option value="static">static</option>
</select>
<input type="button" value="设置position" onclick="obj.style.position=Select1.value"/>
<script type="text/javascript">
var obj = document.getElementById('obj');
var Select1 = document.getElementById('Select1');
</script>
复制代码

 

这样由于在FF中诡异的重新加载问题,如果实际应用中确实要隐藏掉object元素,可以设置style.visibility=”hidden”,虽然这样该元素还

是在页面上占着位置。目前还没找到完美的解决方案。 











 

posted on   小小娟  阅读(1876)  评论(2编辑  收藏  举报

编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构

导航

< 2011年2月 >
30 31 1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 1 2 3 4 5
6 7 8 9 10 11 12
点击右上角即可分享
微信分享提示