易截截图软件、单文件、免安装、纯绿色、仅160KB

Javascript怎么在两个窗体之间传值

原文:刘武|Javascript怎么在两个窗体之间传值  
众所周知window.open() 函数可以用来打开一个新窗口,那么如何在子窗体中向父窗体传值呢,其实通过window.opener即可获取父窗体的引用。
如我们新建窗体FatherPage.htm:
XML-Code:
<script type="text/javascript">
function OpenChildWindow()
{
    window.open('ChildPage.htm');  
}
</script>
<input type="text" id="txtInput" />
<input type="button" value="OpenChild" onclick="OpenChildWindow()" />
然后在ChildPage.htm中即可通过window.opener来访问父窗体中的元素:
XML-Code:
<script type="text/javascript">
function SetValue()
{
    window.opener.document.getElementById('txtInput').value
        =document.getElementById('txtInput').value;
    window.close();
}
</script>
<input type="text" id="txtInput" />
<input type="button" value="SetFather" onclick="SetValue()" />
其实在打开子窗体的同时,我们也可以对子窗体的元素进行赋值,因为window.open函数同样会返回一个子窗体的引用,因此FatherPage.htm可以修改为:
XML-Code:
<script type="text/javascript">
function OpenChildWindow()
{
    var child = window.open('ChildPage.htm'); 
    child.document.getElementById('txtInput').value
        =document.getElementById('txtInput').value;
}
</script>
<input type="text" id="txtInput" />
<input type="button" value="OpenChild" onclick="OpenChildWindow()" />
通过判断子窗体的引用是否为空,我们还可以控制使其只能打开一个子窗体:
XML-Code:
<script type="text/javascript">
var child
function OpenChildWindow()
{
    if(!child)   
        child = window.open('ChildPage.htm'); 
     child.document.getElementById('txtInput').value
         


相关文档:

javascript检测 .net Framework

通过请求的header中可以看到  User-Agent 项
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; Tablet PC 2.0; CIBA)
这里记录了本地信息,通过这里的.Net CLR xxxxx,可以判断 ......

纯JavaScript的渐开式幻灯片

html:
<div id="slide-box">      
    <div id="slide">
      <div id="fbshutter" style="width:1px;">
        <img id="bPic" src="images/01.gif" />  </div>
  ......

三种不同位置的JavaScript代码的写法

三种不同位置的JavaScript代码的写法
 客户端脚本JavaScript在写法上其实有很多种方法,它们的放置位置也非常之多。。 下面列举在三种不同的地方写JavaScript代码,实现的效果都是点击按钮button弹出alert警告框
第一种是最常见的,代码如下 html代码
<input type="button" value="按钮1" id=" ......

javascript中Date和string的互转

js是弱类型的 但是某些时候 你还真需要一个date
比如说 指定时间 那么3个小时后是什么时间
这样的函数 自己写就麻烦了
转成Date
var hs = Date.parse('03/02/2009 22:10');
 var d = new Date(hs);
 document.write(d);
 
 document.write('<br/>');
 var h=3.5;
 var arrh= ......

在Updatepanel中使用JAVASCRIPT的问题(转)

在Updatepanel中使用JAVASCRIPT的问题
在UpdatePanle总使用javascript如:Response.Write("<script language='javascript'>alert('" + error.Message.ToString() + "');history.back(-1);</script>"); 时,弹出来一个提示对话框
Sys.WebForms.PageRequestManagerParserErrorException:
The   message ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号