flex调用js文件中的函数以及调用iframe中js函数
2014-06-05 14:39
155 查看
1、flex调用js文件中的函数步骤为
首先在flex项目中加入要调用的js文件,如3dshow.js,
(1)js中:
就是代码中有:
function readytest()
{ alert("nsdjfhsdf"); }
然后在flex的html-template中的index.template.html模板中:
(2)index.template.html中加入:
<scripttype="text/javascript"src="3dshow.js"></script>
最后在flex中的as代码中有:
(3)flex中:
ExternalInterface.call("readytest");
假如有参数的话就是ExternalInterface.call("readytest","参数");
同样变为有参数的function readytest(newname)
{ alert(newname); }
2、flex调用iframe中html里面的js方法
(1)iframe绑定的html文件中有函数:
<scripttype="text/javascript">
function readytest(){ alert("nsdjfhsdf");}
</script>
(2)flex中的标签中有
<code:IFrame source="test.html" width="100%"height="100%" id="testiframe">引用 test.html
然后在flex中as中编写
this.testiframe.callIFrameFunction("readytest");注意这跟上边的不一样。
至此,全部功能实现。
另外还需要注意的有,iframe要绑定的html文件必须要在iis中发布出来,要不iframe不能识别。
项目中调试一定要在iis中发布出来才可能有效果
首先在flex项目中加入要调用的js文件,如3dshow.js,
(1)js中:
就是代码中有:
function readytest()
{ alert("nsdjfhsdf"); }
然后在flex的html-template中的index.template.html模板中:
(2)index.template.html中加入:
<scripttype="text/javascript"src="3dshow.js"></script>
最后在flex中的as代码中有:
(3)flex中:
ExternalInterface.call("readytest");
假如有参数的话就是ExternalInterface.call("readytest","参数");
同样变为有参数的function readytest(newname)
{ alert(newname); }
2、flex调用iframe中html里面的js方法
(1)iframe绑定的html文件中有函数:
<scripttype="text/javascript">
function readytest(){ alert("nsdjfhsdf");}
</script>
(2)flex中的标签中有
<code:IFrame source="test.html" width="100%"height="100%" id="testiframe">引用 test.html
然后在flex中as中编写
this.testiframe.callIFrameFunction("readytest");注意这跟上边的不一样。
至此,全部功能实现。
另外还需要注意的有,iframe要绑定的html文件必须要在iis中发布出来,要不iframe不能识别。
项目中调试一定要在iis中发布出来才可能有效果
相关文章推荐
- Flex通过IFrame调用JS函数
- js调用其他js文件的函数,以及js加载过程
- Response.Write 调用 JS文件中自定义的函数,jquery、js调用iframe父窗口与子窗口元素的方法
- Flex通过IFrame调用JS函数
- javascript中iframe里面的页面调用父窗口js函数的方法
- iframe里面的页面调用父窗口,左右窗口js函数的方法
- Js文件中调用其它Js函数的方法
- AS与JS相互通信(Flex中调用js函数)
- flex调用js写文件时,传递的参数包含中文,读取乱码问题
- cs文件 调用前台JS函数方法
- javascript(js)iframe里的页面调用父窗口js函数的方法或弹出窗口调用父窗口js函数的方法
- AS与JS相互通信(Flex中调用js函数)
- Iframe之间以及父窗体的函数调用、传值
- javascript中iframe里面的页面调用父窗口js函数的方法
- Js文件中调用其它Js函数的方法
- javascript中iframe里面的页面调用父窗口js函数的方法。
- 关于怎样调用外部的js文件中的函数
- Iframe之间以及父窗体的函数调用、传值(转)
- iframe 之间以及与父窗体的函数调用、值传递
- Flex通过i调用iframe中的js