window.open()与window.showModuleDialog()

一、window.showModalDialog()     模态对话框。 (只支持IE浏览器
window.showModelessDialog()   非模态对话框。

基本语法:vReturnValue = window.showModalDialog(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。

eg:

var obj = new Object();
obj.imageName = document.getElementById('AdvertImage').value;

var  retval = window.showModalDialog("AdvertImageListPre.do",obj, "dialogWidth:800px; dialogHeight:750px; dialogLeft:"+showx+"px; dialogTop:"+showy+"px; status:no; directories:yes;scrollbars:no;Resizable=no;location=no "  );

子页获取父页的值:

window.dialogArguments

eg:PEGetElement("AdvertImage").value=window.dialogArguments.imageName;

父页获取子页的值:

window.returnValue = value;

关闭子窗口:

window.close();

 

二、Window.open()(支持谷歌、火狐)

window.open('page.html', 'newwindow', 'height=100, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')   //该句写成一行代码

 参数解释:
      window.open 弹出新窗口的命令;
  'page.html' 弹出窗口的文件名;
  'newwindow' 弹出窗口的名字(不是文件名),非必须,可用空''代替;
  height=100 窗口高度;
  width=400 窗口宽度;
  top=0 窗口距离屏幕上方的象素值;
  left=0 窗口距离屏幕左侧的象素值;
  toolbar=no 是否显示工具栏,yes为显示;
  menubar,scrollbars 表示菜单栏和滚动栏。
  resizable=no 是否允许改变窗口大小,yes为允许;
  location=no 是否显示地址栏,yes为允许;
  status=no 是否显示状态栏内的信息(通常是文件已经打开),yes为允许;

子页获取父页的值

子页的值赋值给父页的值

关闭窗口

window.close()

判断浏览器类型(这里只判断ie与非ie)

 if (!!window.ActiveXObject || "ActiveXObject" in window){
        ie浏览器
     }else{

   非ie浏览器

}

原文地址:https://www.cnblogs.com/zouhong/p/9478705.html