用过FckEditor的朋友都知道,它的选择图片对话框中“浏览服务器”按钮。点击该按钮可以浏览以前已经上传过的文件。不过这个按钮点击后弹出的对话框在MAXTHON浏览器下是以标签形式打开的,这样模态对话框就始终显示在了浏览文件窗口之前,要想选择文件得先关掉模态对话框。先前有朋友提出把弹出模态对话框的功能改为ShowModlessDialog,这个终究不是解决之道,现将我的解决方法写下来与大家分享:

思路就是基于IE内核的浏览器采用模态对话框弹出浏览服务器窗口,其他的仍然window.open不变

修改\fckeditor\editor\dialog\common\fck_dialog_common.js

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function OpenFileBrowser( url, width, height )
{
     // oEditor must be defined. 
     var iLeft = ( oEditor.FCKConfig.ScreenWidth  - width ) / 2 ;
     var iTop  = ( oEditor.FCKConfig.ScreenHeight - height ) / 2 ;
 
     var sOptions = "toolbar=no,status=no,resizable=no,dependent=yes,scrollbars=yes" ;
     sOptions += ",width=" + width ;
     sOptions += ",height=" + height ;
     sOptions += ",left=" + iLeft ;
     sOptions += ",top=" + iTop ;
 
     // The "PreserveSessionOnFileBrowser" because the above code could be
     // blocked by popup blockers.
     if ( oEditor.FCKConfig.PreserveSessionOnFileBrowser && oEditor.FCKBrowserInfo.IsIE ) {
         // The following change has been made otherwise IE will open the file
         // browser on a different server session (on some cases):
         // http://support.microsoft.com/default.aspx?scid=kb;en-us;831678
         // by Simone Chiaretta.
         var oWindow = oEditor.window.open( url, 'FCKBrowseWindow', sOptions ) ;
 
         if ( oWindow ) {
             // Detect Yahoo popup blocker.
             try
             {
                 var sTest = oWindow.name ; // Yahoo returns "something", but we can't access it, so detect that and avoid strange errors for the user.
                 oWindow.opener = window ;
             } catch(e) {
                 alert( oEditor.FCKLang.BrowseServerBlocked ) ;
             }
        } else {
        	alert( oEditor.FCKLang.BrowseServerBlocked ) ;
        }
     } else {    
          //这里是修改部分
         if(oEditor.FCKBrowserInfo.IsIE)
         {
             window.showModalDialog(url+"&rdm="+new Date(),window,"status:false;dialogWidth:"+width+"px;dialogHeight:"+height+"px\"");
         } else {
             window.open( url, 'FCKBrowseWindow', sOptions ) ;
         }
     }
}

修改\fckeditor\editor\filemanager\browser\default\frmresourceslist.html

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
function OpenFile( fileUrl )
{
    if( window.dialogArguments)
    {
        window.dialogArguments.SetUrl( fileUrl ) ;
        window.close() ;
        window.dialogArguments.focus() ;
    }
    else
    {    
        window.top.opener.SetUrl( fileUrl ) ;
        window.top.close() ;
        window.top.opener.focus() ;    
    }
}

这样就没有问题了。