flex 弹窗口嵌套iframe,移动窗体iframe内容不显示了问题处理

本文档详细介绍了在Flex中使用TitleWindow组件嵌套iframe时遇到的移动窗体导致iframe内容不显示的问题。通过在iframe的初始化和移动事件中进行特定处理,并在外部HTML模板中设置wmode为"transparent",成功解决了这个问题。此外,还提供了如何修改iframe背景色的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一,弹框设置:

创建titlewindow组件内嵌套iframe,名称为UrlForm

<?xml version="1.0" encoding="utf-8"?>
<s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"

...

close="PopUpManager.removePopUp(this);"

initialize="init()" 

 move="titlewindow1_moveHandler(event)">

<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<fx:String id="url"/>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.core.Container;
import mx.events.MoveEvent;
import mx.managers.PopUpManager;
private function init():void
{
ifra.source =url;
}

//窗体移动时,iframe可以跟着移动。若不加此方法则无法移动iframe,因为iframe是div
protected function titlewindow1_moveHandler(event:MoveEvent):void
{
//标记组件,以便在稍后屏幕更新期间调用该组件的 updateDisplayList() 方法。
ifra.invalidateDisplayList();
}


]]>
</fx:Script>

<flexiframe:IFrame id="ifra" width="850" height="520" horizontalCenter="0" source="" />

</s:TitleWindow>

主窗体调用弹窗体:script代码

var urlF:UrlForm=new UrlForm();

urlF.url="http://www.baidu.com";
//下面的代码可以起到居中弹出的效果;
urlF.x=FlexGlobals.topLevelApplication.stage.stageWidth/2- urlF.width/2;  
urlF.y=FlexGlobals.topLevelApplication.stage.stageHeight/2- urlF.height/2;

PopUpManager.addPopUp(urlF, map, true);   
PopUpManager.centerPopUp(urlF); 

二,移动窗体iframe内容不显示了问题处理:

模板index.template.html 中的:

1,script脚本加入

params.wmode = "transparent";

如下:

 var params = {};
            params.quality = "high";
            params.bgcolor = "${bgcolor}";
            params.allowscriptaccess = "sameDomain";
            params.allowfullscreen = "true";
            params.wmode = "transparent";

2,<noscript>中加入

<param name="wmode" value="transparent" />

如下:

<object ....

...

<param name="allowFullScreen" value="true" />
<param name="wmode" value="transparent" />

ok,完成


若是要修改iframe的背景色,则需要找到iframe源码中的IFrameExternalCalls.as中的:

"newDiv.style.backgroundColor = '#FFFFFF';" 
修改为要设置的颜色

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值