window.open
打开窗口时,可以很轻松的取得其父窗口。项目中需要用 showModalDialog打开窗口,想要取得父窗口值,而且还要在 open的基础上修改
为了不让 window.returnValue 所返回的值不是那么烦索,就要想办法如何用showModalDialog
打开的窗口取得其父窗口。何理利用 showModalDialog 传入的参数便可以解决这个问题。
话不多说,看例子:
a.html ---->父窗口
<html>
<head>
<script type="text/javascript" >
function showDialog(){
// 这里边的东西可以自己着情设置
var param = "dialogWidth:400px;dialogHeight:300px;scroll:no;status:no;resizable:no";
// 打开 b.html,并将当前 window做为参数传入弹出窗口中
return window.showModalDialog("b.html", window
, param);
}
</script>
<title></title>
</head>
<body>
<input type="button" value="弹出" onclick="showDialog()"/>
<input type="text" value="父窗口值" name="farValue" id="farValue" />
</body>
b.html ---->子窗口
<html>
<head>
<script type="text/javascript" >
function getParValues(){
// 接收父窗口传过的 window对象.
var parWin= window.dialogArguments;
parWin.document.getElementById("farValue").value = "子窗口改变的值";
}
</script>
<title></title>
</head>
<body>
<input type="button" value="改变父窗口值" onclick="getParValues()" />
</body>
这里有几个需要注意:showModalDialog,在传参数的时候,可以是任意类型。以上例子中是以父窗口的window对象为参数传过去的.你在子窗口取到了父的window对象,你就可以在子窗口里为所欲为了。呵呵
分享到:
相关推荐
This is a `window.showModalDialog()` shim using a modal HTML5 `<dialog>` element and ECMAScript 6 Generators. It was tested in the latest Google Chrome with the *Enable Experimental JavaScript* flag ...
window.showModalDialog以及window.open用法简介
NULL 博文链接:https://shawnfree.iteye.com/blog/598885
针对window.showmodaldialog弹出窗体无刷新的详细使用
window.showModalDialog以及window.open用法简介
window.showModalDialog的基本用法
javascript代码模块之\Window.ShowModalDialog使用手册
使用window.showModalDialog的程序员都知道,该方法可返回值。但是如果遇到跨域时,就返回为underfine。本文档通过iframe镶嵌页面解决该问题。
关于struts2里用javascript刷新window.showModalDialog的父页面
window.showModalDialog&&open.docx
主页面用window.showModalDialog的时候,如果直接打开其它系统的页面,这时候别人的页面在window.returnValue=1;这样返回值的时候,主页面是取不到返回值的,原因就是因为跨域了.
javascript代码模块之window.showModalDialog方法的使用
Window.ShowModalDialog使用手册_对话框 .txt 详细
JS 弹出对话框window.showModalDialog,级联方式,可以返回传值给页面
1> window.showModalDialog()采用JS原理实现,同时父窗口不可操作,window.open()采用新创建一个窗口,同时父窗口可操作; 2> 父窗口与子窗口传递值的方式也有所不同,在子窗口中操作父窗口也语法也不同,分别为var...
下面先说说window.showModalDialog的基本用法 showModalDialog() (IE 4+ 支持)showModelessDialog() (IE 5+ 支持)window.showModalDialog()方法用来创建一个显示HTML内容的模态对话框。window.showModelessDialog()...
本文实例讲述了js的window.showModalDialog及window.open用法。分享给大家供大家参考。具体分析如下: 一、window.open()支持环境: JavaScript1.0+/JScript1.0+/Nav2+/IE3+/Opera3+ 二、基本语法: window.open...
一个是window.showModalDialog()方法,后者是存在父子关系的一种弹出窗口,只有子窗关闭,父窗口才激活,并且可以传送参数和返回值。正好又温习一遍用法,顺便在此记录过程中遇到的问题。 基本介绍: ...