window.open()与window.showModalDialog区别

弹出窗口两种方式:
    1.window.showModalDialog:
      var feature = "dialogWidth:615px;dialogHeight:505px;status:no;help:no;scroll:no;resizable:no;center:yes";
      window.showModalDialog(url, Object(传给弹出窗口的参数,可以是任何类型),feature) 
      决定窗口的外观是第三个参数feature,其中center属性指定为"yes",弹出窗口居中;
      如果想手动指定弹出窗口的具体位置,去掉center属性,
       用dialogTop(弹出窗口上边界居屏幕上的距离)
       dialogLeft(弹出窗口左边界居屏幕左的距离)属性
      如:(距离是px像素),这里手动指定弹出窗口位置居中
      var iTop = (window.screen.availHeight-550)/2; //获得窗口的垂直位置,550为弹出窗口的height;
      var iLeft = (window.screen.availWidth-640)/2; //获得窗口的水平位置,640为弹出窗口的width;
      var feature = "dialogWidth:640px;dialogHeight:550px;status:no;help:no;scroll:no;resizable:no;dialogTop:'+iTop+';dialogLeft:'+iLeft+';";
    2.window.open:  
      var feature = "width=615,height=505,menubar=no,toolbar=no,location=no,scrollbars=no,status=no,modal=yes"
      window.open(url, "name(只能为字符串,不能传window)", feature) 
      手动指定弹出窗口位置,属性top:(弹出窗口上边界居屏幕上的距离)
                            属性left:(弹出窗口左边界居屏幕左的距离)
      下面指定弹出窗口位置居中(这种方式没有center属性):
       var iTop = (window.screen.availHeight-550)/2; //获得窗口的垂直位置,550为弹出窗口的height;
      var iLeft = (window.screen.availWidth-640)/2; //获得窗口的水平位置,640为弹出窗口的width;
      var feature = "width=615,height=505,top="+iTop+",left="+iLeft+",menubar=no,toolbar=no,location=no,scrollbars=no,status=no,modal=yes";
   
   子窗口调用父窗口的东东(控件或者方法):
   1. window.open打开的子窗口有window.opener属性
     子窗口通过window.opener.xxxx获得父窗口的东东。
     如:window.opener.document.getElementById("userName");得到父页面的控件。
       window.opener.fresh();调用父页面的js方法。
   2. window.showModalDialog:不支持window.opener,
      子窗口通过window.dialogArguments.xxxx获得父窗口的东东。
      父窗口通过showModalDialog(url,para,feature)第二个参数para传参数给子窗口,
      子窗口通过window.dialogArguments获得父窗口穿过来的东西。
      
      如:这里传父页面的window过去
        父页面:showModalDialog(url,window,feature)
       子页面:var name = window.dialogArguments.document.getElementById("userName").value;得到父页面的控件。
            var name = window.dialogArguments.fresh();调用父页面的方法。
      这里的window.dialogArguments里的window代表父页面的window,它是通过showModalDialog方法的第二个参数window传过来的,
      当然也可以传数组或其它变量。

window.open()与window.showModalDialog区别的更多相关文章

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

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

  2. window.parent与window.opener、window.showModalDialog的区别 opener和showModalDialog刷新父页面的方法

    项目中使用案例: 父窗体 <s:form namespace="/forexagent" id="listSearchForm" name="t ...

  3. (转)window.open和window.showModalDialog的区别

    window.open和window.showModalDialog区别: 1.都是在IE上打开新窗口,只不过前者是非阻塞式,也可以说非模态窗口.而后者是阻塞式模态窗口.阻塞或者模态窗口,只有你把当前 ...

  4. window.parent与window.openner区别介绍

    今天总结一下js中几个对象的区别和用法: 首先来说说 parent.window与top.window的用法 "window.location.href"."locati ...

  5. JavaScript(Iframe、window.open、window.showModalDialog)父窗口与子窗口之间的操作

    一.Iframe 篇 公共部分 //父对象得到子窗口的值 //ObjectID是窗口标识,ContentID是元素ID function GetValue(ObjectID,ContentID) { ...

  6. JavaScript中,window.opener是什么?window.parent和window.opener有啥区别?

    来自CSDN的问答: window.opener是什么啊? ++++++++++++++++++++++++++++++++++++++++++++++++++ 弹出本窗体的句柄 比如你想点一个按钮直 ...

  7. 总结JavaScript(Iframe、window.open、window.showModalDialog)父窗口与子窗口之间的操作

    一.Iframe 篇 //&&&&&&&&&&&&&&&&&&a ...

  8. 网站开发进阶(二十)JS中window.alert()与alert()的区别

    JS中window.alert()与alert()的区别 前言 alert与window.alert没什么区别,如果有人觉得有区别,那就来解释一下:所有以window.开始的语句,都可以直接把wind ...

  9. JS教程:window.location使用方法的区别

    介绍了window.location使用方法的区别. window.location.href=&http://www.jbxue.com/javascript/ldquo;url”:改变ur ...

随机推荐

  1. iOS之改变UIAlertViewController字体的颜色

    NSString *message = @"请确认信息是否正确?"; NSString *title = @"提示"; UIAlertController *a ...

  2. 一站式学习Redis 从入门到高可用分布式实践

    1:redis 是用c语言来实现的,速度快 持久化 单线程 复杂的数据类型有bitmap和hyperloglog和geo地理信息2:高可用.分布式 v2.8开始支持Redis-Sentinel(哨兵) ...

  3. 判断FreeMarker是否为空

    转自:https://blog.csdn.net/lwt976647637/article/details/73135933 (1)判断Map数据是否为空 <#ifmaster??&&a ...

  4. linux 学习第八天

    一.特殊权限 1.SUID 让命令的执行者临时获取到了所有者权限(rws) 2.SGID 让目录中新的文件的所有组,归属上级目录 3.SBIT 粘滞位 让目录内的文件只能被文件所有者删除 4.修改文件 ...

  5. linux系统基础之--进程计划(基于centos7.4 1708)

  6. 安装psutil时提示缺少python.h头文件(作记录)

    通过pip或者源码安装psutil,都会提示缺少python.h头文件,错误提示如下: ... psutil/_psutil_common.c:9:20: fatal error: Python.h: ...

  7. CYQ MAction,子表 新增,删除,修改 集合

    using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threa ...

  8. JSP/Servlet开发——第二章 JSP数据交互(一)

    1. JSP内置对象:JSP内置对象是 Web 容器创建的一组对象:   ●JSP常用的内置对象:out.request.application.session.response等: ●内置对象不需要 ...

  9. SQL Server 2012 - 动态SQL查询

    动态SQL的两种执行方式:EXEC @sql 和 EXEC sys.sp_executesql @sql DECLARE @c_ids VARCHAR(200) SET @c_ids ='1,2' - ...

  10. redis之闪电内幕

    一.简介和应用 二.Redis的对象redisObject 三.String 四.List 4.1 linkedlist(双端链表) 4.2 ziplist(压缩列表) 五.Hash 六.Set 七. ...