基本介绍:
          showModalDialog()         (IE 4+ 支持)
          showModelessDialog()      (IE 5+ 支持)
          window.showModalDialog()                  方法用来创建一个显示HTML内容的模态对话框。
          window.showModelessDialog()             方法用来创建一个显示HTML内容的非模态对话框。
使用方法:
          vReturnValue = window.showModalDialog(sURL [, vArguments] [,sFeatures])
          vReturnValue = window.showModelessDialog(sURL [, vArguments] [,sFeatures])
参数说明:
         sURL          --  必选参数,类型:字符串。用来指定对话框要显示的文档的URL。
         vArguments    -- 可选参数,类型:变体。用来向对话框传递参数。传递的参数类型不限,包括数组等。对话框通过

window.dialogArguments来取得传递进来的参数。
         sFeatures     -- 可选参数,类型:字符串。用来描述对话框的外观等信息,可以使用以下的一个或几个,用分号“;”隔开。
----------------
1.    dialogHeight:    对话框高度,不小于100px
2.    dialogWidth:    对话框宽度。
3.    dialogLeft:     离屏幕左的距离。
4.    dialogTop:     离屏幕上的距离。
5.    center:          { yes | no | 1 | 0 } :              是否居中,默认yes,但仍可以指定高度和宽度。
6.    help:             {yes | no | 1 | 0 }:                是否显示帮助按钮,默认yes。
7.    resizable:       {yes | no | 1 | 0 } [IE5+]:     是否可被改变大小。默认no。
8.    status:          {yes | no | 1 | 0 } [IE5+]:      是否显示状态栏。默认为yes[ Modeless]或no[Modal]。
9.    scroll:            { yes | no | 1 | 0 | on | off }:是否显示滚动条。默认为yes。

下面几个属性是用在HTA中的,在一般的网页中一般不使用。
10.    dialogHide:{ yes | no | 1 | 0 | on | off }:在打印或者打印预览时对话框是否隐藏。默认为no。
11.    edge:{ sunken | raised }:指明对话框的边框样式。默认为raised。
12.    unadorned:{ yes | no | 1 | 0 | on | off }:默认为no。

参数传递:
1. 要想对话框传递参数,是通过vArguments来进行传递的。类型不限制,对于字符串类型,最大为4096个字符。也可以传递对象,例如:
-------------------------------
parent.htm
<script>
          var obj = new Object();
          obj.name="51js";
          window.showModalDialog("modal.htm",obj,"dialogWidth=200px;dialogHeight=100px");
</script>
modal.htm
<script>
          var obj = window.dialogArguments
          alert("您传递的参数为:" + obj.name)
</script>
-------------------------------
2.可以通过window.returnValue向打开对话框的窗口返回信息,当然也可以是对象。例如:
------------------------------
parent.htm
<script>
          str =window.showModalDialog("modal.htm",,"dialogWidth=200px;dialogHeight=100px");
          alert(str);
</script>
modal.htm
<script>
          window.returnValue="http://homepage.yesky.com";
</script>

常见技巧:

一、怎样才让在showModalDialog和showModelessDialog的超连接不弹出新窗口?
  在被打开的网页里加上<base target="_self">就可以了。这句话一般是放在<head>之间的。

二、怎样才刷新showModalDialog和showModelessDialog里的内容?
  在showModalDialog和showModelessDialog里是不能按F5刷新的,又不能弹出菜单。这个只能依靠

javascript了,以下是相关代码:

<body onkeydown="if (event.keyCode==116){reload.click()}">
<a id="reload" href="filename.htm" style="display:none">reload...</a>

  将filename.htm替换成网页的名字然后将它放到你打开的网页里,按F5就可以刷新了,注意,这个要

配合<base target="_self">使用,不然你按下F5会弹出新窗口的。

三、如何用javascript关掉showModalDialog(或showModelessDialog)打开的窗口。
  <input type="button" value="关闭" onclick="window.close()">
  也要配合<base target="_self">,不然会打开一个新的IE窗口,然后再关掉的。

四、Math.random与showModalDialog。

当你设置的弹出网页固定时(如上面的"modal.htm"页面),ie很可能到临时文件区,下载上次产生的该页面(openPage.html),而没有重新加载,

对于动态加载的页面来说,这样往往产生误会,如没有及时更新数据,也就更不利于开发者测试。所以,你可以采用如下方式:

var strPage = “/medal.htm?random="+Math.random();

这样每次产生的strPage是不一样的,原因也就不言自明了。

showModalDialog介绍的更多相关文章

  1. JS子父窗口互相操作取值赋值的方法介绍

    $("#父窗口元素ID",window.parent.document); 对应javascript版本为window.parent.document.getElementById ...

  2. JS中showModalDialog 详细使用

    基本介绍: showModalDialog() (IE 4+ 支持) showModelessDialog() (IE 5+ 支持) window.showModalDialog() 方法用来创建一个 ...

  3. JS中showModalDialog 详细使用(转)

    基本介绍: showModalDialog()         (IE 4+ 支持) showModelessDialog()      (IE 5+ 支持) window.showModalDial ...

  4. window.open || window.showModalDialog || window.showModelessDialog

    http://dwcmayday201204063551.iteye.com/blog/1621751 http://www.cnblogs.com/zhangyi85/archive/2009/09 ...

  5. 对话框(alert,prompt,confirm,showModalDialog)

    alert大部分浏览器中会产生阻塞,confirm,prompt都会产生阻塞 关于showModalDialog的介绍:(转自JS中showModalDialog 详细使用) 基本介绍:        ...

  6. showModalDialog(转)

    基本介绍:          showModalDialog()         (IE 4+ 支持)          showModelessDialog()      (IE 5+ 支持)    ...

  7. js中的open和showModalDialog

    一.window.open()支持环境: JavaScript1.0+/JScript1.0+/Nav2+/IE3+/Opera3+ 二.基本语法:window.open(pageURL,name,p ...

  8. JS中模态窗口(showModalDialog)的详细使用

    基本介绍: showModalDialog() (IE + 支持) showModelessDialog() (IE + 支持) window.showModalDialog() 方法用来创建一个显示 ...

  9. window.open、window.showModalDialog和window.showModelessDialog 的区别[转]

    一.前言 要打开一个可以载入页面的子窗口有三种方法,分别是window.open.window.showModalDialog和window.showModelessDialog. open方法就是打 ...

随机推荐

  1. Linux 系统位数以及 Linux 软件位数查看

    一. Linux系统位数查看: getconf LONG_BIT uname -a 二. 软件位数查看: file ....txt ![](https://images2018.cnblogs.com ...

  2. Linux下架构高可用性网络----HA+LB+lvs

    实验总拓扑: IP规划: Director1:     eth0      192.168.10.136/28 eth1      192.168.11.2/24 Director2:     eth ...

  3. Java编程的逻辑 (66) - 理解synchronized

    ​本系列文章经补充和完善,已修订整理成书<Java编程的逻辑>,由机械工业出版社华章分社出版,于2018年1月上市热销,读者好评如潮!各大网店和书店有售,欢迎购买,京东自营链接:http: ...

  4. git 服务器新建仓库 远程仓库

    Git 服务器搭建 上一章节中我们远程仓库使用了 Github,Github 公开的项目是免费的,但是如果你不想让其他人看到你的项目就需要收费. 这时我们就需要自己搭建一台Git服务器作为私有仓库使用 ...

  5. JavaScript:数据类型

    JavaScript中数据类型分为两种: 1.基本数据类型 string number boolean null undefined 2.引用类型 数组.Object.function 一.基本数据类 ...

  6. linux安装android sdk

    https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip 1,先安装java https://developer.and ...

  7. 《C++程序设计教程——给予Visual Studio 2008》读书笔记1,2章

    double *p1;       //p1为指向double型的指针变量 POINT *p2;       //p2为指向POINT型(点类型)的指针变量 int (*p3)[6];     //p ...

  8. 使用STC-ISP向KEIL添加STC芯片头文件

    第一步:打开“STC-ISP”软件. 第二步:点击右手边“Keil仿真设置”,然后点击“添加型号和头文件到Keil中添加STC仿真器驱动到Keil中”. 第三步:在弹出的“浏览文件夹”对话框中,找到你 ...

  9. webdriver 执行完毕关闭chromedriver进程

    RT 背景:一个网站的登录部分用到了selenium,但是在多次登录之后,发现进程里残留了很多的chromedriver.exe进程.项目打成jar包之后放到另外的机器上跑,发现不久之后就开始卡顿,甚 ...

  10. 用OpenGL实现跳跃的立体小球

    一.目的 掌握OpenGL中显示列表对象的使用方法. 二.示例代码 Github地址 #include "stdafx.h" #include <GL/glut.h> ...