ckeditor中的图片上传弹出窗口无法在Google Chrome中使用

时间:2012-04-20 09:03:07

标签: javascript ckeditor

当我在ckeditor中单击浏览服务器时,图像浏览器弹出窗口没有出现。我只在Google Chrome中遇到问题。我使用的是Google Chrome的18.0.1025.152版本 enter image description here

我在ckeditor / plugins / popup / plugin.js中进行了更改

    try
    {
        // Chrome 18 is problematic, but it's not really needed here (#8855).
        var ua = navigator.userAgent.toLowerCase();
        if ( ua.indexOf('chrome/18' ) == -1 )
        {
            popupWindow.moveTo( left, top );
            popupWindow.resizeTo( width, height );
        }
        popupWindow.focus();
        popupWindow.location.href = url;
    }
    catch ( e )
    {
        popupWindow = window.open( url, null, options, true );
    }

我点了这个链接enter link description here 但我无法解决问题。任何人都可以帮忙

3 个答案:

答案 0 :(得分:1)

如果您编辑源文件,则必须再次repackage。更新到CKEditor 3.6.3并获取所有其他错误修复程序要简单得多。

答案 1 :(得分:1)

我正在使用opencart 1.5.1.3 ckeditor。我编辑/admin/view/javascript/ckeditor/ckeditor.js并将javascript代码重新调整为http://jsbeautifier.org/

我尝试过使用ckeditor社区的补丁并进行少量修改。有用! http://dev.ckeditor.com/ticket/8855

因此,如果有人在opencart中遇到类似我的类似问题,您可以尝试以下更改。

+++ b/v1.5.1.3/admin/view/javascript/ckeditor/ckeditor.js
@@ -9190,8 +9190,21 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
         var s = window.open('', null, p, true);
         if (!s) return false;
         try {
-             s.moveTo(r, q);
-             s.resizeTo(n, o);
+             // s.moveTo(r, q);
+             // s.resizeTo(n, o); 
+             // Chrome 18 is problematic, but it's not really needed here (#8855). 
+             var ua = navigator.userAgent.toLowerCase(); 
+             var useResize = true; 
+             if (ua.indexOf('chrome') > -1) { 
+                 var chromeVersion = ua.replace(/^.*chrome\/([\d]+).*$/i, '$1') 
+                 if(chromeVersion >= 18) { 
+                     useResize = false; 
+                 } 
+             }  
+             if (useResize) {
+                 s.moveTo( r, q ); 
+                 s.resizeTo( n, o ); 
+             } 
              s.focus();
              s.location.href = m;
         } catch (t) { 

答案 2 :(得分:0)

我正在使用与primefaces-extensions捆绑在一起的CKEditor 3.6.2,因此升级并不那么容易。但是对页面执行以下修复也有效。我将它粘贴在配置文件中,以确保在初始化CKEDITOR变量后触发它。

    CKEDITOR.editor.prototype['popup'] = function( url, width, height, options ) {
        width = width || '80%';
        height = height || '70%';

        if ( typeof width == 'string' && width.length > 1 && width.substr( width.length - 1, 1 ) == '%' )
            width = parseInt( window.screen.width * parseInt( width, 10 ) / 100, 10 );

        if ( typeof height == 'string' && height.length > 1 && height.substr( height.length - 1, 1 ) == '%' )
            height = parseInt( window.screen.height * parseInt( height, 10 ) / 100, 10 );

        if ( width < 640 )
            width = 640;

        if ( height < 420 )
            height = 420;

        var top = parseInt( ( window.screen.height - height ) / 2, 10 ),
                left = parseInt( ( window.screen.width  - width ) / 2, 10 );

        options = ( options || 'location=no,menubar=no,toolbar=no,dependent=yes,minimizable=no,modal=yes,alwaysRaised=yes,resizable=yes,scrollbars=yes' ) +
                ',width='  + width +
                ',height=' + height +
                ',top='  + top +
                ',left=' + left;

        var popupWindow = window.open( '', null, options, true );

        // Blocked by a popup blocker.
        if ( !popupWindow )
            return false;

        try
        {
            // Chrome 18 is problematic, but it's not really needed here (#8855).
            var ua = navigator.userAgent.toLowerCase();
            if ( ua.indexOf( ' chrome/18' ) == -1 )
            {
                popupWindow.moveTo( left, top );
                popupWindow.resizeTo( width, height );
            }
            popupWindow.focus();
            popupWindow.location.href = url;
        }
        catch ( e )
        {
            popupWindow = window.open( url, null, options, true );
        }

        return true;
    }


    $(document).ready(
            function() {
                setContentHeight();
                makeInstructionsTogglable();
                window.onbeforeunload = function() {
                    if (editor.isDirty()) {
                        return "Are you sure you want to navigate away? You have unsaved changes."
                    }
                };
            }
    );
    $(window).resize(function() {
        setContentHeight();
    });