window.showModalDialog基础
本文转载:http://www.cnblogs.com/sunnycoder/archive/2010/05/05/1728047.html
基本知识
l showModalDialog() (IE 4+ 支持)
l showModelessDialog() (IE 5+ 支持)
l window.showModalDialog()方法用来创建一个显示HTML内容的模态对话框。
l window.showModelessDialog()方法用来创建一个显示HTML内容的非模态对话框。
使用方法
var returnValue = window.showModalDialog(sURL[,vArguments][,sFeatures]);
var returnValue = window.showModelessDialog(sURL[,vArguments][,sFeatures]);
参数说明
|
参数名称 |
性质 |
类型 |
作用 |
|
sURL |
必选 |
字符串 |
用来指定对话框要显示的网页的URL。 |
|
vArguments |
可选 |
任何类型 |
用来向对话框传递参数。参数类型不限。 对话框通过window.dialogArguments来取得传递进来的参数。 |
|
sFeatures |
可选 |
字符串 |
用来描述对话框的外观等信息 |
sFeatures参数说明
|
参数名称 |
参数属性 |
说明 |
|
dialogHeight |
npx |
对话框高度,不小于100px |
|
dialogWidth |
npx |
对话框宽度 |
|
dialogLeft |
npx |
离主窗口左的距离 |
|
dialogTop |
npx |
离主窗口上的距离 |
|
center |
{yes | no | 1 | 0 } |
窗口是否居中,默认yes |
|
help |
{yes | no | 1 | 0 } |
是否显示帮助按钮,默认yes |
|
resizable |
{yes | no | 1 | 0 } |
是否可改变大小,默认no |
|
status |
{yes | no | 1 | 0 } |
是否显示状态栏,默认为yes[ Modeless]或no[Modal] |
|
dialogHide |
{ yes | no | 1 | 0 | on | off } |
在打印或者打印预览时对话框是否隐藏,默认为no |
|
scroll |
{ yes | no | 1 | 0 | on | off } |
指明对话框是否显示滚动条,默认为yes |
|
edge |
{ sunken | raised } |
指明对话框的边框样式,默认为raised |
|
unadorned |
{ yes | no | 1 | 0 | on | off } |
默认为no |
注意:dialogHide,edge,unadorned这三个属性是用在HTA(HTML Aplication)中的,一般网页上用不到。
参数传递
通过vArguments来传递参数,类型不限制,对于字符串类型,最大为4096个字符,也可以传递对象,例如:
a.html
|
var p = { Name: "Sunny D.D", Age: 25 }; window.showModalDialog("b.html", p); |
b.html
|
alert(window.dialogArguments.Name); |
当显示b.html页面时,会弹出对话框,内容为“Sunny D.D”。
返回值
通过window.returnValue向打开对话框的窗口返回信息,也可以是对象。例如:
a.html
|
window.showModalDialog("b.html"); alert(window.returnValue.Name); |
b.html
|
var p = { Name: "Sunny D.D", Age: 25 }; window.returnValue = p; |
当关闭b.html页面时,会弹出对话框,内容为“Sunny D.D”。
防止模态窗口打开新窗口
在页面的 <body>标签前加入<base target="_self">:
|
<head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>测试页</title> <base target="_self" /> </head> <body> </body> |
调用父窗口的属性或者方法
参数方式
因为vArguments参数的类型没有限制,所以可以将父窗体对象作为参数的一个属性传递至子窗体:
parent.htm
|
<script> function show() {//父窗口的方法 alert("show"); } var arg = new Object(); //传递进去的参数 arg.win = window; //把当前窗口的引用当参数传进去 arg.str = "argument"; //要传进去的其他参数 window.showModalDialog("son.htm", arg, 'help:no'); </script> |
son.htm
|
<script> var arg = window.dialogArguments; alert(arg.str); arg.win.show(); //调用父窗口的方法 </script> |
window.parent方式
在子窗体中,可以使用语句window.parent来获取父窗体对象,从而调用父窗体的属性与方法:
parent.htm
|
<script> function show() {//父窗口的方法 alert("show"); } window.showModalDialog("son.htm"); </script> |
son.htm
|
<script> window.parent.show(); //调用父窗口的方法 </script> |
window.showModalDialog基础的更多相关文章
- 让IE8在win7下面能显示使用window.showmodaldialog弹出窗口的地址状态栏
问题来源:最近又要对老的系统进行改善,由于用到了window.showmodaldialog这个方法弹出窗口,比如从主界面弹出新增或者修改窗口,如下图所示,显示没有地址栏,进行代码修改还要找到相应的文 ...
- window.showModalDialog的简单实践
Super.jsp - 父窗口 <%@ page language="java" import="java.util.*" pageEncoding=&q ...
- window.showModalDialog返回值和window.open返回值实例详解
最近在谷歌浏览器下发现一个问题,就是使用谷歌浏览器已经不兼容window.showModalDialog了,所以还是改成使用window.open(). 一.window.showModalDialo ...
- 父窗口window.showModalDialog传值 子窗口window.returnValue返回值
父窗口打开子窗口页面: var fatherWindow = document.all.dealReason;//想传的值 win = window.showModalDialog(strUrl, f ...
- 关于window.showModalDialog的一些配置
关于window.showModalDialog的一些配置 一.window.showModalDialog的滚动条 其实纵向滚动条很好去掉,难办的就是横向滚动条.在Firefox下如果window. ...
- window.open()&&window.showmodaldialog()
open 打开一个新窗口,并装载URL指定的文档,或装载一个空白文档,如果没提供URL的话. 适用于 窗口 语法 window = object.open([URL[,name[,features[, ...
- JavaScript(Iframe、window.open、window.showModalDialog)父窗口与子窗口之间的操作
一.Iframe 篇 公共部分 //父对象得到子窗口的值 //ObjectID是窗口标识,ContentID是元素ID function GetValue(ObjectID,ContentID) { ...
- JS中window.showModalDialog()详解
window.showModalDialog()方法用来创建一个显示HTML内容的模态对话框. window.showModelessDialog()方法用来创建一个显示HTML内容的非模态对话框. ...
- 项目中用到的window.showModalDialog(来自网络)
window.showModalDialog相关: showModalDialog() (IE 4+ 支持) showModelessDialog() (IE 5+ 支持) window.showMo ...
随机推荐
- zoj 2286 Sum of Divisors
// f(n)表示 n的约数和 不包括自己// 给你一个m 求1 到 100万里面 f(n)<=m 的个数// 那么首先要用筛选求出所有出 f(n)// 然后就好办了 // 写好后 看见别人好快 ...
- 【转】使用autolayout常见错误
原文网址:http://www.cnblogs.com/xiaokanfengyu/p/4175091.html 使用autolayout常见错误 1:The view hierarchy is no ...
- 【转】linux中waitpid及wait的用法
原文网址:http://www.2cto.com/os/201203/124851.html wait(等待子进程中断或结束) 表头文件 #include<sys/types.h> ...
- vs 2005中解决找不到模板项
开始-->所有程序-->Microsoft Visual Studio 2005-->Visual Studio Tools-->Visual Studio 2005 Comm ...
- Windows环境自动获取AWR报告
1.双击awr.cmd,通过cmd窗口运行awr.sql cmd.exe /c sqlplus lcam_1230/zcpzg1z_1230@54_orcl @awr.sql awr.cmd 2.aw ...
- Oracle 课程三之表设计
完成本课程的学习后,您应该能够: •普通堆表优点和缺点 •理解rowid •全局临时表优点.缺点和适用场景 •分区表的类型和原理.优点和缺点.适用场景 •表字段的高效设计 •sequence的设计 ...
- 解决WCF大数据量传输 ,System.Net.Sockets.SocketException: 远程主机强迫关闭了一个现有的连接
开发中所用的数据需要通过WCF进行数据传输,结果就遇到了WCF大量传输问题 也就是提示System.Net.Sockets.SocketException: 远程主机强迫关闭了一个现有的连接 网上解决 ...
- OutputCache缓存各参数的说明
Duration 缓存时间,以秒为单位,这个除非你的Location=None,可以不添加此属性,其余时候都是必须的. Location Location当被设置为None时,其余的任何设置将不起作用 ...
- 基本输入输出系统BIOS---键盘输入
基本输入输出系统BIOS概述 硬盘操作系统DOS建立在BIOS的基础上,通过BIOS操纵硬件,例如DOS调用BIOS显示I/O程序完成输入显示,调用打印I/O完成打印输出 通常应用程序应该调用DOS提 ...
- SSH无法连接服务器
服务器版本如下: @kelWEB4:/etc# lsb_release -a LSB Version: :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd ...