首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

怎么调用子窗口的函数

2012-08-13 
如何调用子窗口的函数a.aspx 代码:VB.NET codehtml xmlnshttp://www.w3.org/1999/xhtml head runat

如何调用子窗口的函数
a.aspx 代码:

VB.NET code
<html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server">    <title>主页面</title>    <script type ="text/javascript" language ="javascript" >        function callfun()        {            //调用子窗口函数showmsg();        }    </script></head><body>    <form id="form1" runat="server">    <div>        <input id="Button1" type="button" value="call subfrm" onclick ="callfun()" />        <iframe id="subfrm" src="b.aspx"></iframe>    </div>    </form></body></html>


b.aspx 代码:
VB.NET code
<html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server">    <title>子页面</title>    <script type ="text/javascript" language ="javascript" >        function showmsg()        {            alert("call by mainfrm!");        }    </script></head><body>    <form id="form1" runat="server">    <div>    </div>    </form></body></html>


如何调用
我用window.frames["subfrm"].showmsg(); 提示错误

[解决办法]
document.all.subfrm.contentWindow.showmsg()
[解决办法]
document.frames.subfrm.showmsg();也可以 但不是window.frames
[解决办法]
IFRAME嵌套b.aspx
window.frames[txtFrame].showmsg()

热点排行