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传过来的,
当然也可以传数组或其它变量。
调用js方法实际上是这样:window.方法名();
window.open()与window.showModalDialog的更多相关文章
- JavaScript(Iframe、window.open、window.showModalDialog)父窗口与子窗口之间的操作
一.Iframe 篇 公共部分 //父对象得到子窗口的值 //ObjectID是窗口标识,ContentID是元素ID function GetValue(ObjectID,ContentID) { ...
- 总结JavaScript(Iframe、window.open、window.showModalDialog)父窗口与子窗口之间的操作
一.Iframe 篇 //&&&&&&&&&&&&&&&&&&a ...
- 总结js(Iframe、window.open、window.showModalDialog)父窗口与子窗口之间的操作
http://hi.baidu.com/yashua839/blog/item/131fdb2fe547ef221f3089af.html一.Iframe 篇 //&&&&am ...
- window.open()与window.showModalDialog区别
window.open()与window.showModalDialog区别 弹出窗口两种方式: 1.window.showModalDialog: var feature = &qu ...
- window.open、window.showModalDialog和window.showModelessDialog 的区别[转]
一.前言 要打开一个可以载入页面的子窗口有三种方法,分别是window.open.window.showModalDialog和window.showModelessDialog. open方法就是打 ...
- window.parent与window.opener、window.showModalDialog的区别 opener和showModalDialog刷新父页面的方法
项目中使用案例: 父窗体 <s:form namespace="/forexagent" id="listSearchForm" name="t ...
- (转)window.open和window.showModalDialog的区别
window.open和window.showModalDialog区别: 1.都是在IE上打开新窗口,只不过前者是非阻塞式,也可以说非模态窗口.而后者是阻塞式模态窗口.阻塞或者模态窗口,只有你把当前 ...
- window.parent与window.openner区别介绍
今天总结一下js中几个对象的区别和用法: 首先来说说 parent.window与top.window的用法 "window.location.href"."locati ...
- window.onload和window.document.readystate的探究
在编写前端页面的时候,我们时常需要对页面加载的状态进行判断,以便进行相应的操作. 比如在移动端,时常需要在页面完全加载完成之前,先显示一个loading的图标,等待页面完成加载完成后,才显示出真正要展 ...
- window.location.href = window.location.href 跳转无反应 a 超链接 onclick 点击跳转无反应
错误写法 , 主要是在 href="#"这里 <a href="#" id="send" onclick="return b ...
随机推荐
- 12月6日 看Active Record validation ; 做jdstore ,注意gem bootstrap 版本只支持bootstrap3。
Active Record validation: new_record?()//用于验证刚新建,但没存入database中的数据 ,返回true或false persisted?() //和new_ ...
- hdu-4289 最大流Dinic模板题
拆点,套模板. 详情见代码. // // main.cpp // hdu_4289 // // Created by Luke on 16/8/29. // Copyright © 2016年 Luk ...
- UVA-11882 Biggest Number (DFS+剪枝)
题目大意:给出一个方格矩阵,矩阵中有数字0~9,任选一个格子为起点,将走过的数字连起来构成一个数,找出最大的那个数,每个格子只能走一次. 题目分析:DFS.剪枝方案:在当前的处境下,找出所有还能到达的 ...
- UVA-12186 Another Crisis (树状DP)
题目大意:一家工厂,一个老板(编号为0),n个工人(编号1~n),其中,有的工人是中层领导,管辖一部分其他工人.现在大家要签署一份加薪申请书,但是按照规定不能越级上访,所以只能通过一层层的中间领导传到 ...
- UVA-1533 Moving Pegs (路径寻找问题)
Description Venture MFG Company, Inc. has made a game board. This game board has 15 holes and thes ...
- 68. Text Justification *HARD*
Given an array of words and a length L, format the text such that each line has exactly L characters ...
- List原理
ArrayList: ArrayList是一个可变数组实现,实现了List接口的所有方法,并允许存取null值.ArrayList基本上等同与Vector,但它只对writeObject()和read ...
- HTTP使用 multipart/form-data 上传多个字段(包括文件字节流 octet-stream)
自己用到的一个向服务器上传多个字段的实例,代码不全,仅做参考. 用的是WinINet,上传的字段中包括文件字节流 /* PHttpRequest中自行组装body之后,HttpSendRequest中 ...
- 【转载】Android Bug分析系列:第三方平台安装app启动后,home键回到桌面后点击app启动时会再次启动入口类bug的原因剖析
前言 前些天,测试MM发现了一个比较奇怪的bug. 具体表现是: 1.将app包通过电脑QQ传送到手机QQ上面,点击安装,安装后选择打开app (此间的应用逻辑应该是要触发 [闪屏页Activity] ...
- java基本类型的大小
1个字节是8位byte 1字节short 2字节int 4字节long 8字节float 4字节double 8字节char 2字节boolean 1字节======================= ...