`
hgfghe3
  • 浏览: 50616 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

window.opener 的用法

 
阅读更多

  window.open()支持环境: JavaScript1.0+/JScript1.0+/Nav2+/IE3+/Opera3+ 基本语法: window.open(pageURL,name,parameters) 其中: pageURL 为子窗口路径 name 为子窗口句柄 parameters 为窗口参数(各参数用逗号分隔) 示例:    脚本运行后,page.html将在新窗体newwindow中打开,宽为100,高为400,距屏顶0象素,屏左0象素,无工具条,无菜单条,无滚动条,不可调整大小,无地址栏,无状态栏。 上例中涉及的为常用的几个参数,除此以外还有很多其他参数,如下所示: 各项参数 其中yes/no也可使用1/0;pixel value为具体的数值,单位象素。 参数 | 取值范围 | 说明 alwaysLowered | yes/no | 指定窗口隐藏在所有窗口之后 alwaysRaised | yes/no | 指定窗口悬浮在所有窗口之上 depended | yes/no | 是否和父窗口同时关闭 directories | yes/no | Nav2和3的目录栏是否可见 height | pixel value | 窗口高度 hotkeys | yes/no | 在没菜单栏的窗口中设安全退出热键 innerHeight | pixel value | 窗口中文档的像素高度 innerWidth | pixel value | 窗口中文档的像素宽度 location | yes/no | 位置栏是否可见 menubar | yes/no | 菜单栏是否可见 outerHeight | pixel value | 设定窗口(包括装饰边框)的像素高度 outerWidth | pixel value | 设定窗口(包括装饰边框)的像素宽度 resizable | yes/no | 窗口大小是否可调整 screenX | pixel value | 窗口距屏幕左边界的像素长度 screenY | pixel value | 窗口距屏幕上边界的像素长度 scrollbars | yes/no | 窗口是否可有滚动栏 titlebar | yes/no | 窗口题目栏是否可见 toolbar | yes/no | 窗口工具栏是否可见 Width | pixel value | 窗口的像素宽度 z-look | yes/no | 窗口被激活后是否浮在其它窗口之上 用函数控制弹出窗口 下面是一个完整的代码。    function openwin() { window.open ("page.html", "newwindow", "height=100, width=400, toolbar =no, menubar=no, scrollbars=no, resizable=no, location=no, status=no") //写成一行 }    任意的页面内容...   这里定义了一个函数openwin(),函数内容就是打开一个窗口。怎么调用呢? 方法一:  浏览器读页面时弹出窗口; 方法二:  浏览器离开页面时弹出窗口; 方法三: 用一个连接调用: 打开一个窗口 注意:使用的"#"是虚连接。 方法四: 用一个按钮调用:  如何实现在不使用window.showModalDialog 的情况下用 window.open方式 向父窗口返回值。 例如: 页面AAA.htm 用 window.open方式弹出页面 BBB.htm 。 在页面BBB.htm上选择一个值,确定关闭窗口后将选择的这个值返回到父窗口AAA.htm。 AAA.htm得到返回的值后,给本页面上的文本框赋值。 BBB.htm页面中加入下面代码: window.opener.document.getElementById("theTextArea Id").value = document.getElemnetById("theSelectId").value ; window.opener 的用法 window.opener 返回的是创建当前窗口的那个父窗口的引用,比如点击了a.htm上的一个链接而打开了b.htm,然后我们打算在b.htm上输入一个值然后赋予a.htm上的一个id为"name"的textbox中,就可以写为: window.opener.document.getElementById("name").valu e = "输入的数据"; 对于javascript中的window.opener没有很好的理解。 为什么框架中不能使用,弹出窗口的父窗口不能在框架里面的某个页面呢?那怎样通过弹出窗口操作框架中的父窗口呢? opener.parent.frames['frameName'].document.all.inp ut1.value 即opener这个对象为前一个窗口,可以使用window.opener.document...调用document的相关方法,例如下面的例子,插入一些table行到前一个窗口: function taletoTb(itemStr) { newRow = opener.document.all.itemTb.insertRow(opener.docume nt.all.itemTb.rows.length); rowCnt = opener.document.all.itemTb.rows.length; newCell = newRow.insertCell(); newCell.insertAdjacentHTML('BeforeEnd',''+itemCode+''); newCell = newRow.insertCell(); newCell.insertAdjacentHTML('BeforeEnd',''+itemName+''); newCell = newRow.insertCell(); newCell.insertAdjacentHTML('BeforeEnd',''); } 11:56 浏览 (159) 评论 (0) 分类: JavaScript 2008-02-27 缩略显示confirm用法和例子 一般用于弹出对话框(确定/否) 确定:就执行其嵌套的内容;否:则反之  //验证时间格式 YYYY-MM-DD/YYYY,MM,DD function isDate(date){ var regu = "^[0-9]{4}-([0-1]?)[0-9]{1}-([0-3]?)[0-9]{1}$"; var re = new RegExp(regu); if (date.search(re) != -1) return true; else return false; } function sureButton(){ if(!confirm('真的要删除吗?删除后将无法恢复!')){ return; } //验证时间格式 YYYY-MM-DD var startDate=document.getElementById("startDate").val ue; var endDate=document.getElementById("endDate").value; if(!isDate(startDate)){ alert(startDate+"请输入正确的开始日期格式!如:(YYYY-MM-DD)2008-01-01"); return document.getElementById("startDate").focus(); } if(!isDate(endDate)){ alert("请输入正确的结束日期格式!如:(YYYY-MM-DD)2008-01-01"); return document.getElementById("endDate").focus(); } if(startDate==""){ alert("请输入开始日期"); return document.getElementById("startDate").focus(); } if(endDate==""){ alert("请输入结束日期"); return document.getElementById("endDate").focus(); } startDate=startDate.replace(new RegExp('-', 'g'),'/'); alert(startDate); endDate=endDate.replace(new RegExp('-', 'g'),'/'); var startTime=new Date(startDate).getTime(); alert(new Date(startDate).getTime()); var endTime=new Date(endDate).getTime(); if((endTime-startTime)         table{color: #000000; font-family: 宋体; font-size: 12px; height:12 } t1{color:#008000;align:center}          开始日期   结束日期            当前状态   无效 等待 显示中   Logo行宽   1 2 3 4 5 6  显示顺序             ::日期格式为年-月-日,直接填入图片和点击路径全名时应仔细查对是否正确::      可以批量删除表格记录行,通过checkbox选择删除的行;可以批量增加记录行,通过输入框指定行数。    The page of append rows to Table  // 新增行 function addRow(){ var textNum = document.getElementById("rownum"); // 得到新增行记录的行数 var index = textNum.value; if(!checknum(index)){ alert("You can only input number in the TEXT!"); textNum.focus(); textNum.select(); } for(var i = 0; i '; newtext1.innerHTML = ''; newtext2.innerHTML = ''; newtext3.innerHTML = ''; // 新增的tr节点下增加td节点 newRowObj.appendChild(newCheckBox); newRowObj.appendChild(newtext1); newRowObj.appendChild(newtext2); newRowObj.appendChild(newtext3); // tbody节点下增加tr节点 tableBodyObj.appendChild(newRowObj); } } // 新增行数选择框检查输入必须是数字 function checknum(strVal){ if (strVal.length != 0){ var r = strVal.match(new RegExp(/^[0-9]+$/)); if (r == null){ return false; }else{ return true; } } return true; } // 批量删除指定的行 function deleteRow(){ var Tblen; // 得到所有 checkbox 对象 var checkbox = document.getElementsByName("checkbox"); //var checkboxlen = document.all.checkbox.length; // 得到所有提交的checkbox个数 var checkboxlen = checkbox.length; var ischecked; // 得到删除按钮对象 var delbutton = document.getElementById("delete"); for (var i=0; i  动态添加、删除行,分别通过insertRow,deleteRow方法实现,显示行号,通过rowIndex属性获得,基本可以动态实现相关功能。  var cGetRow=-99999; var lineNo = 1; function _(id) { return document.getElementById(id); } // The index of the row to be deleted. // This index starts from 0 and is relative to the logical order (not document order) // of all the rows contained inside the table. // If the index is -1 the last row in the table is deleted. function AddRow(){ //添加一行 var newTr = _("tab1").insertRow(); //添加两列 var newTd0 = newTr.insertCell(); var newTd1 = newTr.insertCell(); //设置列内容和属性 newTd0.innerHTML = ''; // 测试动态改变innerHTML中的checkbox的id alert(_("box" + lineNo).id); newTd1.innerText= '新增加行' + lineNo; lineNo++; } function DelRow(iIndex){ //删除一行 if(iIndex==-99999){ alert("系统提示:没有选中行号!"); }else{ iIndex = cGetRow; _("tab1").deleteRow(iIndex); } } function GetRow(){ //获得行索引 //两个parentElement分别是TD和TR哟,rowIndex是TR的属性 //this.parentElement.parentElement.rowIndex cGetRow=window.event.srcElement.parentElement.pare ntElement.rowIndex; } function ShowRow(){ //显示行号 alert(cGetRow); //alert(document.getElementsByTagName("tr").length ); }     第一行    第二行    第三行      统计      表格动态增加行 
分享到:
评论

相关推荐

    javascript window.opener的用法分析

    window.opener 的用法 window.opener 返回的是创建当前窗口的那个窗口的引用,比如点击了a.htm上的一个链接而打开了b.htm,然后我们打算在b.htm上输入一个值然后赋予a.htm上的一个id为“name”的textbox中,就可以写...

    window.opener用法和用途实例介绍

    window.opener,是通过window.open打开子窗体的父窗体的引用。 比如在父窗体parentForm里面,通过window.open(“subForm.html”),那么在subform.html中window.opener就代表parentForm。既然在子窗体中能够拿到父窗体...

    [removed].reload 刷新使用分析(去对话框)

    使用[removed].reload;刷新时,如果提交数据的动作,则会出现讨厌的对话框! 解决此问题,应该这样写: [removed].href=[removed].href; [removed].reload; 同理,如果是刷新父窗口,应该这样写: window.opener...

    深入学习JavaScript中的bom

    BOM(Broswer Object Model) 凡是 window 的属性和方法,均可以省略“window.” ...2.在子窗口中使用,表示父窗口的window对象 window.opener window.opener.fatherSayHello(); 调用父窗口的方法 window.opener.a

    react-new-window:using使用`window.open`在React中弹出新窗口

    为React 16构建(使用ReactDOM.createPortal )。 阻止弹出窗口的处理程序(通过onBlock prop)。 根据父窗口或屏幕使弹出窗口居中。 安装 npm i react-new-window --save 用法 import React from 'react' import...

    js弹出窗口返回值

    window.opener 的用法在一般的用法中,只是用来解决封闭窗口时不提示弹出窗口, 而对它更深层的懂得一般斗劲少。其 实 window.opener是指调用window.open办法的窗口。 在工作中主如果用来解决项目组提交的。这种...

    javascript常用对象梳理

    熟练掌握window对象的status、location、name、self、opener属性的使用 Window对象是客户端javascript最高层对象之一,只要打开浏览器窗口,不管该窗口中是否有打开的网页,当遇到BODY、FRAMESET或FRAME元素时,...

    新浪网易的评论块制作源码

    新浪网易的评论块制作源码 技术要点: 1.因为 textarea里面不能放图片,所以和新浪的做法一样,选用iframe放内容,然后隐藏一个 textarea...window.opener.XXX(xxx); 运行项目执行 HTMLPage2.htm 页面,进行测试吧

    JS中表单的使用小结

    使用window.open()弹出的弹出窗口,刷新父窗口 window.opener.location.reload() 使用window.showDialog弹出的模式窗口 window.dialogArguments.location.reload(); 2.javascript弹出窗口的两种实现方式 —下面给...

    JS中showModalDialog关闭子窗口刷新主窗口用法详解

    网上找了好长时间 大都是window.opener.location.reload(),等等 都不是我想要的 最后终于发现了一个 想知道的就往下看看吧 showModalDialog和showModelessDialog 一、showModalDialog和showModelessDialog有什么不同...

    js setTimeout opener的用法示例详解

    } setTimeout : 延迟多长时间执行什么方法,具体使用://www.jb51.net/article/35535.htm opener: 指parent表示父窗口,比如一个A页面利用iframe或frame调用B页面,那么A页面所在窗口就是B页面的parent。...

    javascript showModalDialog,open取得父窗口的方法

    通常使用window.open的方式开启新窗口的话 要取得父窗口的控件,可以用window.opener来取得父窗口 然而如果使用showModalDialog的话…却无效 如果有需要的话,需要修改开启的语法以及showModalDialog中的语法 开启...

    107个常用javascript语句

    72.JS中指定当前打开窗口的父窗口:window.opener,支持opener.opener...的多重继续. 73.JS中的self指的是当前的窗口 74.JS中状態栏显示內容:window.status="內容" 75.JS中的top指的是框架集中最顶层的框架 76.JS中...

    JS模态窗口返回值兼容问题的完美解决方法

    因系统要兼容原IE已使用的关闭方法,经调试测得,需对window.dialogArguments进行再较验,不然易出问题。 function OKEnd(vals) { if (vals == null) vals = TRUE; if (typeof (window.opener) == undefined) { ...

    JavaScript 定时器 SetTimeout之定时刷新窗口和关闭窗口(代码超简单)

    废话不多说了,直接给大家贴代码了。...使用定时器实现JavaScript的延期执行或重复执行 window对象提供了两个方法来实现定时器的效果,分别是 window.setTimeout()和window.setInterval。其中前者可以使一段

    javascript函数的解释

    72.JS中指定当前打开窗口的父窗口:window.opener,支持opener.opener...的多重继续. 73.JS中的self指的是当前的窗口 74.JS中状态栏显示内容:window.status="内容" 75.JS中的top指的是框架集中最顶层的框架 76.JS中...

    js关闭子窗体刷新父窗体实现方法

    代码如下: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/–>使用open方式打开的窗体 //使用地址... 使用showModalDialog方法 window.returnValue = ‘refresh’;

    不提示直接关闭网页窗口的JS示例代码

    在IE7、IE8中,使用JavaScript提供的close()方法都可以关闭当前窗口或标签,但都提示讨厌的对话框,找了下代码,终于可以无提示直接关闭了。 JavaScript代码 代码如下:function CloseWin() { window.opener=null;...

Global site tag (gtag.js) - Google Analytics