现在做的项目中后台文章有添加附件的功能,用的是js在当前窗口前弹出一个小的模态窗口,从而添加附件。
今天遇到一个在火狐下弹出模态窗口会有错误,因为模态窗口中要加载的页面在根目录下,在ie 谷歌等浏览器中会识别
"\\a.aspx"这种写法定位到根目录,火狐下不会识别,而会在当前窗口路径后直接查找“\\a.aspx”,所以会有错。
现在找到一种解决办法,在火狐下来代替 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‘);
if ($.browser.mozilla) { ReturnStr = window.open("/PClass/app/UpLoad/upload.aspx?rnd=" + number + "&upFileStr=" + upFileStr + "&upPathStr=" + upPathStr + "&FileSizeStr=" + FileSizeStr + "&ModuleID=" + ModuleID + "&FileDes=" + FileDes + "", this, "modal=yes,width=400px,height=440px,resizable=no,scrollbars=no,Top=200px, edge=Raised, center= Yes, help= no,scroll= yes, status= no"); } else { //火狐下获取该路径 错误 ,不会返回到根目录获取。 ReturnStr = window.showModalDialog("\\PClass\\app\\UpLoad\\upload.aspx?rnd=" + number + "&upFileStr=" + upFileStr + "&upPathStr=" + upPathStr + "&FileSizeStr=" + FileSizeStr + "&ModuleID=" + ModuleID + "&FileDes=" + FileDes + "", this, "dialogHeight:300px; dialogWidth:440px; dialogTop: 200px; edge: Raised; center: Yes; help: no;scroll: yes; resizable: no; status: no;"); }
原文:http://blog.csdn.net/itmaxin/article/details/18735817