站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Javascript 专题javascript/Jscript实现父子窗体的互相引用问题(Powered By ZosaTapo)

javascript/Jscript实现父子窗体的互相引用问题(Powered By ZosaTapo)

摘要: javascript jscript 窗体引用
<textarea readonly style="border:none;font-family:Courier New;line-height:150%;width:760px;overflow-y:visible">

Title:
javascript/Jscript实现父子窗体的互相引用问题(Powered By ZosaTapo)

Key Words:
javascript jscript 窗体引用

Content:
近来有很多网友问关于如何利用javascipt实现弹出窗体与父窗体功能引用问题。
本人在以前的使用有一些这方面的体验,希望与大家分享一下。希望能对需要的网友有一些帮助。

本文主要以例子为主,文后附有全部源代码。
实现父窗体,子窗体引用的关键在于下面几点:
(1)window.open.函数返回值是弹出子窗体的引用句柄。
(2)得到父窗体引用句柄。这是功能实现的关键,说起来也很简单。
self.opener返回窗体的父窗体。
(3)self,window,parent,top等实现的窗体引用是针对帧(frame/frameset)实现的,跟本文关系不大的。你如果利用parent得不到弹出窗体的父窗体的。

本文只是针对窗体之间引用做简单的分析说明。源代码只是提供简单演示,很不完善,如果使用的话,请自己增加相应的出错检查等功能。


<head>
Welcome to ZosaTapo's WebSite:::::::::Powered By ZosaTapo
<script LANGUAGE="JavaScript">

function openwindow(){
if(child==null){
child=window.open("child.htm");
}
}

function callmethod(){
if(child!=null){
child.testC();
}
}

function closewindow(){
if(child!=null){
child.close();
child=null;
}
}
//
</script>

</head>

<body bgcolor="#000000">

Open child Window:

<input type="button" value="Open Child Window" onclick="openwindow();">

Call child Method:

<input type="button" value="Call Child Method" onclick="callmethod();">

Close child Window:

<input type="button" value="Close Child Window" onclick="closewindow();">


<head>
Welcome to ZosaTapo's WebSite:::::::::Powered By ZosaTapo
<script LANGUAGE="JavaScript">

function changetext(){
if(parwindow!=null){
parwindow.document.all("author").value="zosatapo";
}
}

function callmethod(){
if(parwindow!=null){
parwindow.testP();
}
}

function closewindow(){
if(parwindow!=null){
parwindow.close();
parwindow=null;
}
}
//
</script>

</head>

<body bgcolor="#000000">


Call parent Method:

<input type="button" value="Call Parent Method" onclick="callmethod();">

Close parent Window:

<input type="button" value="Close Parent Window" onclick="closewindow();">


</textarea>
↑返回目录
前一篇: javascript函数速查
后一篇: 一个javascript脚本写的俄罗斯方块