本帖最后由 jsj321 于 2009-10-21 11:33 编辑
昨天发现SupeSite/XSpace4.0的日志编辑器有bug,也就是在IE8下点击“插入表情”、“文本颜色”等的时候是弹出一个新的标签页,而不是弹出模态对话框,并且在弹出的对话框中选择表情的时候报错“dialogArguments is undefined”。
一开始我以为是IE8中不支持dialogArguments 了,但是发现不对,因为IE8下“弹出一个新的标签页,而不是弹出模态对话框”,因为IE8是支持showModelessDialog/showModelessDialog、很显然在IE8下调用的不是showModalDialog或者showModelessDialog,而是window.open,打开编辑器的文件/images/edit/edit.js,看到function oPenWin函数的定义:
- function oPenWin(_sTitle, _sWidth, _sHeight, _sUrl, _bDialog, _open){
- xposition=0; yposition=0;
- if ((parseInt(navigator.appVersion) >= 4 )) {
- xposition = (screen.width - _sWidth) / 2;
- yposition = (screen.height - _sHeight) / 2;
- }
- if(_open) {
- window.open(_sUrl,"win","menubar=no,location=no,resizable=no,scrollbars=no,status=no,left="+xposition+",top="+yposition+",width="+_sWidth+",height="+_sHeight);
- } else {
- if(window.Event) {
- window.open(_sUrl,"win","menubar=no,location=no,resizable=no,scrollbars=no,status=no,left="+xposition+",top="+yposition+",innerWidth="+_sWidth+",innerHeight="+_sHeight);
- } else {
- if(_bDialog == true) {
- showModelessDialog(_sUrl, window, "dialogHeight:"+(_sHeight+20)+"px;dialogWidth:"+_sWidth+"px;status:no;help:no;resizable:yes;status:no;tustatus:no;");
- } else {
- showModalDialog(_sUrl, window, "dialogHeight:"+(_sHeight+20)+"px;dialogWidth:"+_sWidth+"px;status:no;help:no;resizable:yes;status:no;tustatus:no;");
- }
- }
- }
复制代码 不知道它在哪判断来判断去到底是调用window.open还是showModelessDialog还是showModalDialog是在做什么,用这么复杂吗?直接调用showModalDialog/showModelessDialog不就行了吗?反正你调用window.open在对话框中也没法用dialogArguments (因为用window.open打开的窗口是得不到dialogArguments 的)。
所以修改如下,在if(_open) {上增加:
- if(_bDialog == true)
- {
- showModelessDialog(_sUrl, window, "dialogHeight:"+(_sHeight+20)+"px;dialogWidth:"+_sWidth+"px;status:no;help:no;resizable:yes;status:no;tustatus:no;");
- } else
- {
- showModalDialog(_sUrl, window, "dialogHeight:"+(_sHeight+20)+"px;dialogWidth:"+_sWidth+"px;status:no;help:no;resizable:yes;status:no;tustatus:no;");
- }
- return;
复制代码 搞定!
演示地址: http://www.rupeng.com/ |