There can be no Triumph without Loss,No Victory without Suffering,No Freedom without Sacrifice.
All you have to decide is what to do with the time that is given to you.
Get busy Living, or Get busy Dying?
  首页 | 留言给我 | 订阅 Rss | CLI | 黄白之恋 Posts:158   Hits: 5544925    Comments: 173    
 日历归档
<<  <  2024 - 11  >  >>
SuMoTuWeThFrSa
     12
3456789
10111213141516
17181920212223
24252627282930
 About Me
 Name: ZhangSichu
 Sex: Male
 Age: 32
 Email: ZhangSichu@gmail.com
 MSN: ZhangSichu@hotmail.com
 Home: ZhangSichu.com
 WeiBo: weibo.com/zhangsichu
 个人推荐
 分类归档
  ·C++/C(5)  RSS
  ·软件工程(1)  RSS
  ·杂事/随感(26)  RSS
  ·.Net/Java(30)  RSS
  ·面向对象程序设计(5)  RSS
  ·汇编/破解(0)  RSS
  ·平面设计(3)  RSS
  ·SQL(5)  RSS
  ·COM/COM+(2)  RSS
  ·Web开发(81)  RSS
 My Friends
Back Forward Refresh Home 2024年11月22日 星期五 RSS CLI Mine Sweeper. In Javascript.

  Module Dialog In IE & FF
字体大小 [ ]

本文原始内容来自公司的Community Server 经过自己修改和编辑。
本文实现了一个在IE和FF下都可以正常使用的ModuleDialog。
主要使用window.open方法打开Dialog。
使用window.onclick=function (){DialogWin.focus()};和event.cancelBubble = true;保证弹出窗口的Module样式。
详细内容:
ParentWindow
function OpenDialog()
{
if(window.document.all)//IE
{
//参数
var strPara = "dialogHeight:200px;dialogWidth:300px;help:off;resizable:off;scroll:no;status:off";
//传入的值
var strPassIn=window.document.getElementById("txtReturn").value;
//打开模态对话框
var strReturn=window.showModalDialog("ChildOpenWindow.htm",strPassIn,strPara);
//处理返回值
if(typeof(strReturn) != undefined)
{
window.document.getElementById("txtReturn").value=strReturn;
}
}
else//FireFox
{
//参数
var strPara = "dialogHeight:200px;dialogWidth:300px;help:off;resizable:off;scroll:no;status:off;modal=yes;dialog=yes";
var strPassIn=window.document.getElementById("txtReturn").value;

//注册事件
window.myAction=this;

//打开窗口
var DialogWin = window.open("ChildOpenWindow.htm","myOpen",strPara,true);

//传入参数
window.myArguments=strPassIn;

this.returnAction=function(strResult){
//处理返回结果
if(typeof(strResult) != undefined)
{
window.document.getElementById("txtReturn").value=strResult;
}
}

//处理打开窗口最上显示(不完美)
window.onclick=function (){DialogWin.focus()};
event.cancelBubble = true;
}
}

ChildWindow
function window_onload()
{
if(window.document.all)//IE
{
//对于IE直接读数据
var txtInput=window.document.getElementById("txtInput");
txtInput.value=window.dialogArguments;
}
else//FireFox
{
//获取参数
window.dialogArguments=window.opener.myArguments;
var txtInput=window.document.getElementById("txtInput");
txtInput.value=window.dialogArguments;
}
}

function OnOKClick()
{
//对于IE或者FireFox都需要设置returnValue进行返回值设定
var inputStr=window.document.getElementById("txtInput").value;
returnValue=inputStr;
window.close();
}

function window_onunload() {
//对于Firefox需要进行返回值的额外逻辑处理
if(!window.document.all)//FireFox
{
window.opener.myAction.returnAction(window.returnValue)
}
}
</script>
注册onload
<body language="javascript" onload="return window_onload()" onunload="return window_onunload()">
  Posted @ 1/8/2007 1:55:36 PM | Hits (100258) | Comment (0

  Post Comment
标题 *
作者 *
密码 记住我
评论 *
    


Stable in Firefox 1.5 2.0Stable in IE6 IE7Stable in MozillaStable in Netscape
ZhangSichu.com V0.1.7507
Powered By ZhangSichu
Copyright © ZhangSichu
Download ZhangSichu.com source code. Download source code