window.showModalDialog在Firefox无法支持
2017-07-25 15:34
344 查看
以下内容复制的,记录一下 原地址:http://blog.csdn.net/kongtoubudui/article/details/7576374
在网页程序中,
有时我们会希望使用者按下按钮后开启一个保持在原窗口前方的子窗口,
而在IE中,我们可以使用showModalDialog来达成,
语法如下 :
vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures])
范例:
window.showModalDialog(“openwin.html”,”Arguments”,”dialogHeight: 200px; dialogWidth: 200px; dialogTop: 10px; dialogLeft: 10px; edge: Raised; center: Yes; help: Yes; resizable: Yes; status: Yes;”);
但是.在Firefox中却没有showModalDialog这东西,
而在FireFox中我们只能使用window.open实现这样的功能,
window.open的语法如下 :
oNewWindow = window.open( [sURL] [, sName] [, sFeatures] [, bReplace])
只是,在Firefox下,window.open的参数中,sFeature多了一些功能设定,
而在FireFox下要让开启的窗口跟IE的showModalDialog一样的话,
只要在sFeatures中加个modal=yes就可以了,
范例如下:
window.open(‘openwin.html’,’newWin’,’modal=yes,width=200,height=200,resizable=no,scrollbars=no’);
提到了子窗口,不得不提的就是子窗口跟母窗口间的交互操作,
因为我想很多人开启对话窗口应该都是为了将操作完的结果丢回去给母窗口…
如果是用showModalDialog的话,
在子窗口中要存取母窗口的函数的话,
要注意两个地方,
1.(母窗口中)开启窗口:
window.showModalDialog(“openwin.html”,self,’modal=yes,width=775,height=700,resizable=no,scrollbars=no’);
在第二个参数(vArguments),改成self.
2.(子窗口中)调用母窗口的函数:
window.dialogArguments.ShowMsg(obj.value);
ShowMsg为母窗口中的函数.
而使用window.open的话,
则是要注意一个地方,
1.(子窗口中)调用母窗口的函数:
window.opener.ShowMsg(obj.value);
使用window.opener去接母窗口的对象.
如此一来,只要再透过navigator.appName去判断浏览器为何,
就可以写一个IE与FireFox兼容的函数…
例子如下:
在一个父窗口中打开一个子窗口,并把子窗口的值传递给父窗口
在父窗口中:
function colorpick(obj){
if (window.showModalDialog!=null)//IE判断
{
var smd= window.showModalDialog("Default2.aspx","","dialogWidth:225px;dialogHeight:170px;status:no;help:no;scrolling=no;scrollbars=no");
if(smd!=null)
obj.style.background=rtn;
return;
}
else
{
this.returnAction=function(strResult){
if(strResult!=null)
obj.style.background=strResult;
}
window.open("Default2.aspx","","width=225,height=170,menubar=no,toolbar=no,location=no,scrollbars=no,status=no,modal=yes");
return;
}
}
在子窗口中:
function act(RGB) {
if (window.showModalDialog!=null)//IE判断
{
parent.window.returnValue=”#”+RGB;
window.close();//firefox不支持
}
else
{
window.opener.returnAction(“#”+RGB);
top.close();//IE和FireFox都支持
}
}
在网页程序中,
有时我们会希望使用者按下按钮后开启一个保持在原窗口前方的子窗口,
而在IE中,我们可以使用showModalDialog来达成,
语法如下 :
vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures])
范例:
window.showModalDialog(“openwin.html”,”Arguments”,”dialogHeight: 200px; dialogWidth: 200px; dialogTop: 10px; dialogLeft: 10px; edge: Raised; center: Yes; help: Yes; resizable: Yes; status: Yes;”);
但是.在Firefox中却没有showModalDialog这东西,
而在FireFox中我们只能使用window.open实现这样的功能,
window.open的语法如下 :
oNewWindow = window.open( [sURL] [, sName] [, sFeatures] [, bReplace])
只是,在Firefox下,window.open的参数中,sFeature多了一些功能设定,
而在FireFox下要让开启的窗口跟IE的showModalDialog一样的话,
只要在sFeatures中加个modal=yes就可以了,
范例如下:
window.open(‘openwin.html’,’newWin’,’modal=yes,width=200,height=200,resizable=no,scrollbars=no’);
提到了子窗口,不得不提的就是子窗口跟母窗口间的交互操作,
因为我想很多人开启对话窗口应该都是为了将操作完的结果丢回去给母窗口…
如果是用showModalDialog的话,
在子窗口中要存取母窗口的函数的话,
要注意两个地方,
1.(母窗口中)开启窗口:
window.showModalDialog(“openwin.html”,self,’modal=yes,width=775,height=700,resizable=no,scrollbars=no’);
在第二个参数(vArguments),改成self.
2.(子窗口中)调用母窗口的函数:
window.dialogArguments.ShowMsg(obj.value);
ShowMsg为母窗口中的函数.
而使用window.open的话,
则是要注意一个地方,
1.(子窗口中)调用母窗口的函数:
window.opener.ShowMsg(obj.value);
使用window.opener去接母窗口的对象.
如此一来,只要再透过navigator.appName去判断浏览器为何,
就可以写一个IE与FireFox兼容的函数…
例子如下:
在一个父窗口中打开一个子窗口,并把子窗口的值传递给父窗口
在父窗口中:
function colorpick(obj){
if (window.showModalDialog!=null)//IE判断
{
var smd= window.showModalDialog("Default2.aspx","","dialogWidth:225px;dialogHeight:170px;status:no;help:no;scrolling=no;scrollbars=no");
if(smd!=null)
obj.style.background=rtn;
return;
}
else
{
this.returnAction=function(strResult){
if(strResult!=null)
obj.style.background=strResult;
}
window.open("Default2.aspx","","width=225,height=170,menubar=no,toolbar=no,location=no,scrollbars=no,status=no,modal=yes");
return;
}
}
在子窗口中:
function act(RGB) {
if (window.showModalDialog!=null)//IE判断
{
parent.window.returnValue=”#”+RGB;
window.close();//firefox不支持
}
else
{
window.opener.returnAction(“#”+RGB);
top.close();//IE和FireFox都支持
}
}
相关文章推荐
- 解决window.showModalDialog在Firefox无法支持
- 解决window.showModalDialog在Firefox无法支持
- 解决window.showModalDialog在Firefox无法支持
- 解决window.showModalDialog在Firefox无法支持
- 解决window.showModalDialog在Firefox无法支持
- 解决firefox不支持window.event.returnValue = false
- Chrome不支持showModalDialog模态对话框和无法返回returnValue的问题
- firefox 默认不支持 window.close();
- window.frames[]在Firefox下无法兼容的解决方式
- javascript showModalDialog传值与FireFox的window.open 父子窗口传值示例第1/2页
- firefox提示 内容编码错误 无法显示您尝试查看的页面,因为它使用了无效或者不支持的压缩格式
- SELENIUM无法支持FIREFOX最新版
- window.showModalDialog浏览器不支持后使用window.open代码问题处理方法
- 【坑】Firefox不支持window.event的解决办法
- BX2001: IE 支持使用 window.clipboardData 访问系统剪贴板,Chrome 和 Safari 中存在类似的 Clipboard 对象但尚未实现,Firefox 和 Opera 不支持这类对象
- Chrome不支持showModalDialog模态对话框和无法返回returnValue的问题
- Firefox不支持removeNode及window.event解决办法
- javascript showModalDialog传值与FireFox的window.open 父子窗口传值示例第1/2页
- 解决firefox在未触发事件前无法使用window.event的问题
- 刚发现 Firefox3 支持showModalDialog了