Flex通过IFrame调用JS函数

首先是下载一个flex-iframe-1.5.1.swc

另外需要下载一个Flex IFrame中文注释使用方法详解 将工程中html-template文件夹中AC_OETags.jsindex.template.html覆盖,否则不会成功,这步是非常重要的,我做的时候就是没有覆盖此处,利用callIFramFuntion调用js函数始终没有反应,且调试运行时IE未弹出“为帮助保护你的安全,Internet Explorer已经限制此文件显示可能访问你的计算机的活动内容.....”,如果弹出说明你成功了。

然后就是代码了,下面我只讲述简单的代码,并为根据原文编写,若要了解更多,转载原文为:

http://hi.baidu.com/qq825129090/blog/item/b2216085a98c442266096ec0.htmlFlex IFrame使用详解[一] 加入IFrme到项目

http://hi.baidu.com/qq825129090/blog/item/b2aa6a48404f4fec83025c01.htmlFlex IFrame使用详解[二] 例子:调用IFrme页面的js函数

代码:

test.mxml中

import mx.controls.Alert;
import mx.events.FlexEvent;

protected function bt_clickHandler(event:MouseEvent):void
{
iFrame.callIFrameFunction("showAlert");
}
]]>
</fx:Script>
<flexiframe:IFrame id="iFrame" borderColor="0xFF0000" borderStyle="solid"
  label="ckeditor"
  source="mytest.html"
  width="532"
  height="447"
  overlayDetection="true"  x="250" y="10" contentBackgroundColor="#BBB1B1"/>
<s:Button id="bt" label="调用内联函数" click="bt_clickHandler(event)"/>


mytest.html中

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function showAlert()
{
alert("1");
}
</script>
</head>
< body>
< /body>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值