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

showModalDialog详解

阅读更多

为了以后查找方便,特粘贴到此!

基本介绍:
          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和showModelessDialog使用心得

    #### showModalDialog详解 `showModalDialog` 方法创建的是一个模态对话框,这意味着当这个对话框打开时,用户无法与主页面或其他非模态对话框进行交互,直到关闭当前对话框。这在需要用户做出决策或输入信息的情况...

    ShowModalDialog与window.open的区别

    #### 二、ShowModalDialog详解 **1. 功能介绍** `ShowModalDialog` 是一个非标准但广泛使用的函数,用于打开模态对话框。模态对话框是指打开后会阻止用户与主页面进行任何交互的窗口,直到该对话框被关闭为止。 *...

    showModalDialog参数详解

    showModalDialog参数详解 基本介绍: showModalDialog() (IE 4+ 支持) showModelessDialog() (IE 5+ 支持) window.showModalDialog()方法用来创建一个显示HTML内容的模态对话框。 window.showModelessDialog()...

    showModalDialog参数使用详解

    在JavaScript的世界里,`showModalDialog`是一个古老但仍然有用的函数,用于打开一个模态对话框,展示用户需要交互的信息。这个功能在处理用户输入、确认操作或展示详细信息时非常实用。本篇文章将深入探讨`...

    showModalDialog用法

    ### showModalDialog用法详解 `showModalDialog`是早期Internet Explorer浏览器中提供的一个用于创建模态对话框的方法。它能够阻止用户与当前页面的其他部分交互,直到对话框被关闭为止。本文将详细介绍`...

    window.showModalDialog的基本用法

    #### 特征参数详解 - **dialogHeight**: 对话框的高度,默认单位为像素(px),对于模态对话框也可以使用 em 单位。 - **dialogWidth**: 对话框的宽度,默认单位为像素(px)。 - **dialogLeft**: 对话框在屏幕上的...

    showModalDialog模态对话框的使用详解以及浏览器兼容

    `showModalDialog`是JavaScript `window`对象的一个方法,它用于打开一个新的模态对话框,与`window.open`相似但有所不同。主要的区别在于,当使用`showModalDialog`打开一个子窗口时,父窗口会失去焦点,用户无法与...

    window.showModalDialog(javascript)

    【window.showModalDialog() 方法详解】 在Web开发中,JavaScript提供了两种对话框方式来与用户交互,即模态对话框和非模态对话框。本文将重点介绍模态对话框的使用方法`window.showModalDialog()`。 模态对话框是...

    js showModalDialog参数的使用详解

    JavaScript中的`showModalDialog`函数是一个专用于创建模态对话框的方法,主要在IE浏览器上得到广泛支持(从IE4开始)。模态对话框意味着用户必须先关闭对话框才能与父窗口进行交互,这在需要用户输入信息或确认操作...

    JS 弹出对话框window.showModalDialog()

    ### JS弹出对话框 `window.showModalDialog()` 的使用与详解 #### 一、`window.showModalDialog()` 概述 在JavaScript中,`window.showModalDialog()` 是一个非标准但广泛使用的API,用于创建模态对话框。模态...

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

    本文实例讲述了JS中showModalDialog关闭子窗口刷新主窗口用法。分享给大家供大家参考,具体如下: 网上找了好长时间 大都是window.opener.location.reload(),等等 都不是我想要的 最后终于发现了一个 想知道的就往下...

    JavaScript中window.showModalDialog()用法详解

    使用showModalDialog()方法,开发者可以控制子窗口的行为,例如窗口的大小、位置、是否可调整大小、是否显示状态栏以及是否显示滚动条等。 该方法的基本语法是: ```javascript vReturnValue = window....

    showModalDialog及dialogArguments使用

    ### showModalDialog及dialogArguments使用详解 在Web开发中,`showModalDialog` 和 `showModelessDialog` 是Internet Explorer浏览器特有的方法,用于打开模态或非模态对话框。这两个函数允许开发者创建自定义的弹...

    js showModalDialog弹出窗口实例详解

    JavaScript 的 `showModalDialog` 方法是用来创建一个模态对话框的,这种对话框在打开时会阻止用户与页面的其他部分交互,直到该对话框被关闭。这种方法在网页开发中常用于表单填写、弹出确认窗口或者进行特定任务如...

    showmodaldialog

    ### JS中的`showModalDialog`与`showModelessDialog`详解 #### 一、概述 在JavaScript编程中,`showModalDialog` 和 `showModelessDialog` 是两个用于创建自定义对话框的方法,它们主要用于Internet Explorer...

    Window.ShowModalDialog使用手册

    ### 使用Window.ShowModalDialog与Window.ShowModelessDialog在JavaScript中的详解 #### 一、引言 在Web开发中,为了实现更加丰富的用户交互体验,开发者经常需要创建模态或非模态对话框来显示特定的信息或者请求...

Global site tag (gtag.js) - Google Analytics