用open和showModalDialog打開新網頁的區別
来源:互联网 发布:小学生读英语软件下载 编辑:程序博客网 时间:2024/06/02 03:06
1、打開新窗口:
open:
window.open("newPage.aspx", null, "height=419, width=566, top=180, left=300, toolbar=no, menubar=no, scrollbars=no,resizable=no, location=no,status=no");
height、width、top、left設置窗口的大小和位置。toolbar、menubar、scrollbar、location是否顯示工具欄、菜單欄、滾動條、地址栏。resizable是否允許改變窗口大小。status 是否显示状态栏内的信息。
也可直接window.open("newPage.aspx");
showModalDialog:
window.showModalDialog("newPage.aspx", null, "dialogHeight:530px;dialogWidth:440px;dialogTop:175px;dialogLeft:300px;help:no;scrollbar:no;resizable:no;status:no");
dialogHeight、dialogWidth、dialogTop、dialogLeft設置窗口的大小和位置。其他參數一樣。
2、觸發父窗口腳本事件:
this.opener.getFatherClick();調用父窗口(FatherPage.aspx)腳本的getFatherClick事件。
但是用open打開時,調用父窗口的事件前要先判斷,父窗口是否還存在。
try
{
var i = this.opener.location.toString().indexOf("FatherPage.aspx");
if(i > 0) //如果i > 0,證明父窗口沒有關閉,還存在。
{
this.opener.getFatherClick();
}
}
catch(exc)
{
}
但是用showModalDialog打開時,不會存在這個問題,因為在操作父界面前,要先關閉newPage頁面,才可操作。
用showModalDialog發父界面返回值的話,用一個更簡單的方法:
在FatherPage頁面寫:
var ret= window.showModalDialog("ProgLov.aspx");
if(ret== -1 || ret== null) return; //沒有返回值時。
alert(ret);
在newPage頁面,關閉時寫:
window.returnValue = value; //value為返回值。
window.close();
3.用showModalDialog打開時,存在一個問題,就是在第一次打開newPage進入頁面時,會執行page_load事件,但是關閉后,再次打開進入頁面時,不會執行page_load事件,除非觸發其他服務器端事件才會執行,好像是因為緩沖的問題。
解決的方法就是,在新頁面newPage的<head></head>之間加<% Response.Expires = -1; %>
- 用open和showModalDialog打開新網頁的區別
- showModalDialog 和open.window的不同
- showModalDialog 和 window.open 的区别
- javaScript--showModalDialog 和 open
- showModalDialog,open的用法
- showModalDialog、showModelessDialog和open 区别
- 关于初用window.open和window.showModalDialog使用的区别
- window.open() 和 window.showModalDialog() 的返回值
- window.showModalDialog模式对话框 和 window.open的区别
- windows.open()和window.showModalDialog()的使用方法
- window.showModalDialog 和 window.open的区别以及用法
- window.showModalDialog模式对话框 和 window.open的区别
- window.showModalDialog和window.open的参数区别
- js中window.open和showModalDialog的区别
- window.open、window.showModalDialog和window.showModelessDialog 的区别
- window.open、window.showModalDialog和window.showModelessDialog 的区别
- window.open、window.showModalDialog和window.showModelessDialog 的区别
- 用window.open代替window.showModalDialog和window.showModelessDialog
- 在客戶端設置控件的顯示/隱藏
- 字符,字节和编码(乱码的产生)
- js访问
- 使用 Nginx 提升网站访问速度
- 图片处理(图片缩小,图片剪辑)
- 用open和showModalDialog打開新網頁的區別
- 在框架窗口中退出
- DES解密时“Base-64字符数组的无效长度”
- javascript cookies 存、取、删除实例
- 使用 Java 2D API 制作艺术动画
- VS2005 VS2008新建网站和新建项目里选Web应用程序区别
- Nginx安装简记(含PHP支持、虚拟主机、反向代理负载均衡)
- 时曦科技成为“深圳通信行业协会会员单位”!
- marquee嵌套这后出现的效果