怎调用另外一个页面里的JavaScript函数啊

zhghl 2004-09-24 09:11:47
多谢
...全文
88 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
歪歪 2004-09-24
  • 打赏
  • 举报
回复
<TABLE cellSpacing=0 cellPadding=1 width="100%" bgColor=#cccc99
border=0><TBODY>
<TR>
<TD width="100%" height=15>
<TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#cccc99
border=0>
<TBODY>
<TR>
<TD vAlign=center align=left bgColor=#eeeecc height=2>
<DIV align=center>操作系统</DIV></TD></TR>
<TR>
<TD vAlign=top bgColor=#ffffff>
<DIV align=center><A
href="http://61.171.118.168/netbook/tech/Windows/">Windows系列</A></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=1 width="100%" bgColor=#cccc99
border=0><TBODY>
<TR>
<TD width="100%" height=73>
<TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#cccc99
border=0>
<TBODY>
<TR>
<TD vAlign=center align=left bgColor=#eeeecc height=2>
<DIV align=center>实用软件</DIV></TD></TR>
<TR>
<TD vAlign=top bgColor=#ffffff height=54>
<DIV align=center><A
href="http://61.171.118.168/netbook/tech/filemange/">管理维护
</A><BR><BR><A
href="http://61.171.118.168/netbook/tech/imagemedia/">多媒体与图像</A>
</DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=1 width="100%" bgColor=#cccc99
border=0><TBODY>
<TR>
<TD width="100%" height=15>
<TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#cccc99
border=0>
<TBODY>
<TR>
<TD vAlign=center align=left bgColor=#eeeecc height=2>
<DIV align=center>冲浪宝典</DIV></TD></TR>
<TR>
<TD vAlign=top bgColor=#ffffff>
<DIV align=center><A
href="http://61.171.118.168/netbook/tech/creatweb/">网络组建</A><BR><BR><A
href="http://61.171.118.168/netbook/tech/goweaver/">入门技巧</A></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR></TD>
<TD vAlign=top height=581><BR>
<TABLE width="100%" border=0>
<TBODY>
<TR>
<TD class=shadow vAlign=center align=middle>子父窗口之间的操作之小例子</TD></TR>
<TR>
<TD class=shadow vAlign=center align=right>
<HR color=#7d561c noShade SIZE=1>
</TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="96%" align=center>
<TBODY>
<TR>
<TD class=f14b vAlign=top><!-- #BeginEditable "cont" --><BR>
<P>
用window.openr打开的子父窗口之间的操作跟框架的是不一样的,子窗口和父窗口之间有opener来联系。而源窗口要访问子窗口要通过其句柄来操作。以下小例子希望能帮助新手更了解他们的操作。</P>
<P><STRONG>test.htm</STRONG>  </P>
<P><html><BR><head><BR><meta
http-equiv="Content-Type" content="text/html;
charset=gb2312"><BR><meta name="GENERATOR" content="Microsoft
FrontPage 4.0"><BR><meta name="ProgId"
content="FrontPage.Editor.Document"><BR><title>子父窗口的操作</title><BR></head><BR><body><BR><script><BR>var
win=null;<BR>function
op(){<BR>win=window.open("about:blank","win","width=200,height=200");<BR>win.document.write("<input
type='button' value='关闭父窗口'
onclick='window.opener.opener=null;window.opener.close()'>");<BR>win.document.write("<input
type='button' value='刷新你窗口'
onclick='window.opener.location.reload()'>");<BR>}<BR></script><BR><input
onclick="op()" value="打开窗口" type="button"><input type="button"
value="最小化"
onclick="if(win&&win.open&&!win.closed){win.resizeTo(0,0);win.moveTo(0,window.screen.width);}else
alert('还没有打开窗口或已经关闭')"><input type="button" value="最大化"
onclick="if(win&&win.open&&!win.closed){win.moveTo(-4,-4);win.resizeTo(screen.availWidth+8,screen.availHeight+8);}else
alert('还没有打开窗口或已经关闭');"><input type=button value="关闭子窗口"
onclick="if(win&&win.open&&!win.closed){win.opener=null;win.close()}else
alert('还没有打开窗口或已关闭')"><input type=button value="刷新子窗口"
onclick="if(win&&win.open&&!win.closed){win.location.reload();win.focus()}else
alert('窗口还没有打开或已关闭')"><input type="button" value="看子窗口的大小"
onclick="if(win&&win.open&&!win.closed){alert(win.document.body.clientWidth+'*'+win.document.body.clientHeight);win.focus();}else{alert('还没有打开窗口或者已关闭')};"><BR></body><BR></html></P>
<P><STRONG>运行效果如下:</STRONG></P>
<P> </P>
<META content="Microsoft FrontPage 4.0" name=GENERATOR>
<META content=FrontPage.Editor.Document name=ProgId>
<SCRIPT>

var win=null;

function op(){

win=window.open("about:blank","win","width=200,height=200");

win.document.write("<input type='button' value='关闭父窗口' onclick='window.opener.opener=null;window.opener.close()'>");

win.document.write("<input type='button' value='刷新你窗口' onclick='window.opener.location.reload()'>");

}

</SCRIPT>
<INPUT onclick=op() type=button value=打开窗口><INPUT onclick="if(win&&win.open&&!win.closed){win.resizeTo(0,0);win.moveTo(0,window.screen.width);}else alert('还没有打开窗口或已经关闭')" type=button value=最小化><INPUT onclick="if(win&&win.open&&!win.closed){win.moveTo(-4,-4);win.resizeTo(screen.availWidth+8,screen.availHeight+8);}else alert('还没有打开窗口或已经关闭');" type=button value=最大化><INPUT onclick="if(win&&win.open&&!win.closed){win.opener=null;win.close()}else alert('还没有打开窗口或已关闭')" type=button value=关闭子窗口><INPUT onclick="if(win&&win.open&&!win.closed){win.location.reload();win.focus()}else alert('窗口还没有打开或已关闭')" type=button value=刷新子窗口><INPUT onclick="if(win&&win.open&&!win.closed){alert(win.document.body.clientWidth+'*'+win.document.body.clientHeight);win.focus();}else{alert('还没有打开窗口或者已关闭')};" type=button value=看子窗口的大小>

<P>以上只供参考,有错请纠正,谢谢!</P><BR><!-- #EndEditable --></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<CENTER>
<SCRIPT language=JavaScript
src="网络社团--技术文档--子父窗口之间的操作之小例子.files/bottom.js"></SCRIPT>

<TABLE cellSpacing=0 cellPadding=0 width=500 align=center border=0>
<TBODY>
<TR>
<TD class=myknotse1 align=middle><BR>本网站所有资料版权归结网络社团所有<BR>© 2002~2003<FONT
color=white size=1></FONT></TD></TR></TBODY></TABLE></CENTER></BODY></HTML>
歪歪 2004-09-24
  • 打赏
  • 举报
回复
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0077)http://61.171.118.168/netbook/tech/javascript/html/javascript.ohchina.167.htm -->
<HTML><HEAD><TITLE>网络社团--技术文档--子父窗口之间的操作之小例子</TITLE><!-- #BeginEditable "doctitle" --><!-- #EndEditable -->
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<STYLE type=text/css>.a {
COLOR: #000000
}
A:active {
COLOR: #000000; TEXT-DECORATION: none
}
A:link {
COLOR: #000000; TEXT-DECORATION: none
}
A:hover {
COLOR: #ff0000; TEXT-DECORATION: underline
}
TABLE {
FONT-SIZE: 9pt
}
.white {
COLOR: #ffffff; TEXT-DECORATION: none
}
.white:active {
COLOR: #ffffff; TEXT-DECORATION: none
}
.white:hover {
COLOR: #ff0000; TEXT-DECORATION: none
}
.white:link {
COLOR: #ffffff
}
.black {
COLOR: #000000; TEXT-DECORATION: none
}
.black:active {
COLOR: #000000; TEXT-DECORATION: none
}
.black:hover {
COLOR: #ff0000; TEXT-DECORATION: none
}
.black:link {
COLOR: #000000; TEXT-DECORATION: none
}
</STYLE>
<LINK href="网络社团--技术文档--子父窗口之间的操作之小例子.files/style.css" type=text/css
rel=stylesheet>
<META content="MSHTML 6.00.2800.1276" name=GENERATOR></HEAD>
<BODY bottomMargin=0 bgColor=#ffffff leftMargin=0 topMargin=0 rightMargin=0
marginwidth="0" marginheight="0">
<DIV align=center>
<SCRIPT language=JavaScript
src="网络社团--技术文档--子父窗口之间的操作之小例子.files/top.js"></SCRIPT>

<SCRIPT language=JavaScript
src="网络社团--技术文档--子父窗口之间的操作之小例子.files/items.js"></SCRIPT>
</DIV>
<TABLE cellSpacing=0 cellPadding=0 width=778 align=center>
<TBODY>
<TR>
<TD vAlign=top width=160 height=581>
<TABLE cellSpacing=0 cellPadding=0 width="100%">
<TBODY>
<TR>
<TD height=52>
<DIV align=center><IMG height=48
src="网络社团--技术文档--子父窗口之间的操作之小例子.files/webdi.jpg"
width=160></DIV></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=1 width="100%" bgColor=#cccc99
border=0><TBODY>
<TR>
<TD width="100%" height=15>
<TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#cccc99
border=0>
<TBODY>
<TR>
<TD vAlign=center align=left bgColor=#eeeecc height=2>
<DIV align=center>网络时代</DIV></TD></TR>
<TR>
<TD vAlign=top bgColor=#ffffff>
<DIV align=center><A
href="http://61.171.118.168/netbook/tech/creatsite/">网站建设</A>
</DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=1 width="100%" bgColor=#cccc99
border=0><TBODY>
<TR>
<TD width="100%" height=84>
<TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#cccc99
border=0>
<TBODY>
<TR>
<TD vAlign=center align=left bgColor=#eeeecc height=2>
<DIV align=center>网页设计</DIV></TD></TR>
<TR>
<TD vAlign=top width="100%" bgColor=#ffffff height=55>
<DIV align=center>
<P><A
href="http://61.171.118.168/netbook/tech/html/">HTML</A><BR><A
href="http://61.171.118.168/netbook/tech/css/">CSS</A><BR><A
href="http://61.171.118.168/netbook/tech/javascript/">JavaScript</A><BR><A
href="http://61.171.118.168/netbook/tech/dreamweaver/">DreamWeaver</A><BR><A
href="http://61.171.118.168/netbook/tech/flash/">Flash</A></P></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=1 width="100%" bgColor=#cccc99
border=0><TBODY>
<TR>
<TD width="100%" height=15>
<TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#cccc99
border=0>
<TBODY>
<TR>
<TD vAlign=center align=left bgColor=#eeeecc height=2>
<DIV align=center>美工教室</DIV></TD></TR>
<TR>
<TD vAlign=top bgColor=#ffffff>
<DIV align=center><A
href="http://61.171.118.168/netbook/tech/fireworks/">Firworks</A><BR><A
href="http://61.171.118.168/netbook/tech/photoshop/">Photoshop</A><BR><A
href="http://61.171.118.168/netbook/tech/3dmax/">3DS
Max</A><BR><A
href="http://61.171.118.168/netbook/tech/CorelDRAW/">CorelDraw</A></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=1 width="100%" bgColor=#cccc99
border=0><TBODY>
<TR>
<TD width="100%" height=15>
<TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#cccc99
border=0>
<TBODY>
<TR>
<TD vAlign=center align=left bgColor=#eeeecc height=2>
<DIV align=center>程序开发</DIV></TD></TR>
<TR>
<TD vAlign=top bgColor=#ffffff>
<DIV align=center><A
href="http://61.171.118.168/netbook/tech/Visualbasic/">Visual
Basic</A><BR><A
href="http://61.171.118.168/netbook/tech/VisualC++/">Visual
C++</A><BR><A
href="http://61.171.118.168/netbook/tech/java/">Java</A><BR><A
href="http://61.171.118.168/netbook/tech/Delphi/">Delphi</A><BR><A
href="http://61.171.118.168/netbook/tech/perl/">Perl</A><BR><A
href="http://61.171.118.168/netbook/tech/php/">PHP</A><BR><A
href="http://61.171.118.168/netbook/tech/asp/">ASP</A><BR><A
href="http://61.171.118.168/netbook/tech/dotnet/">.NET</A><BR><A
href="http://61.171.118.168/netbook/tech/other_language/">其他开发语言</A><BR><A
href="http://61.171.118.168/netbook/tech/database/">数据库开发</A><BR><A
href="http://61.171.118.168/netbook/tech/game/">游戏开发</A><BR><A
href="http://61.171.118.168/netbook/tech/fileformat/">文件格式</A><BR><A
href="http://61.171.118.168/netbook/tech/other/">其
他</A><BR></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
cybernaute 2004-09-24
  • 打赏
  • 举报
回复
最好把一些公用的函数等,放在一个独立的文件里,然后调用!
zltostem 2004-09-24
  • 打赏
  • 举报
回复
----- a.asp -----

<input type=button value=ok onclick="document.frames[0].show();">
<iframe src='b.asp'></iframe>

----- b.asp -----

Is b.asp
<script language="javascript">
<!--
function show()
{
alert('clement');
}
//-->
</script>
whnnet 2004-09-24
  • 打赏
  • 举报
回复
知道窗口对象为winX,可以用
winX.methodXX()
winX.变量d
whnnet 2004-09-24
  • 打赏
  • 举报
回复
2个窗口必须有关系才行,比如:
var xxx = "ok"
a = window.open("b.htm")
在b.htm可以用
alert(opener.xxx)

87,997

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧