如何修复tinymce错误“b.editor is null”

时间:2013-01-30 06:48:35

标签: jquery tinymce

我从 tiny_mce_custom_popup.js 中得到了 b.editor为null 的错误。

b.editor为空错误仅在firefox中发生。怎么解决这个问题?

重现错误。

  1. 加载页面

  2. 重新加载页面

  3. 发生错误。

  4. 这些是我的html页面。

    test1.html

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8">
            <title>Test TinyMCE</title>
    
            <link rel="stylesheet" href="main.css">
    
            <script type="text/javascript" src="jquery.min.js"></script>
        </head>
        <body>
    
    
            <div class="container">
                <div class="insert-media">
                    <div class="insert-popup-button" title="insert media"></div>
                    <div class="insert-popup-container">
                        <iframe name="media-browser" id="media-browser" src="media-popup.html" class="media-browser-dialog iframe-in-dialog"></iframe>
                    </div>
                </div>
                <form method="post">
                    <div class="form-controls">Text input</div>
                    <textarea name="body_value" placeholder="textarea input" rows="10" class="post-body"></textarea>
                    <button type="submit">Save</button>
                    <button type="reset">Reset</button>
                </form>
            </div>
    
    
            <script type="text/javascript" src="tiny_mce/jquery.tinymce.js"></script>
            <script type="text/javascript">
                $(function() {
                    $('.insert-popup-button').click(function() {
                        $('.insert-popup-container').toggle();
                    });
                });
    
    
                $('.post-body').tinymce({
                    // Location of TinyMCE script
                    script_url : 'tiny_mce/tiny_mce.js',
                    apply_source_formatting : true,
                    content_css : 'main.css',
                    convert_urls : false,
                    document_base_url : '/_vlab/test-tinymce/',
                    inline_styles : true,
                    preformatted : false,
                    relative_urls : false,
                    // fix bug when open and tinymce not show in first time.
                    height: '400px',
                    width: '100%'
                });// tinymce post-body
    
    
            </script>
    
    
        </body>
    </html>
    

    媒体-popup.html

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8">
            <title>Media popup</title>
    
            <link rel="stylesheet" href="main.css">
    
            <script type="text/javascript" src="jquery.min.js"></script>
        </head>
        <body>
    
    
            <div class="container media-container">
                <a href="#" onclick="return insert_media('<img src=\'001.jpg\'>');">insert media</a>
            </div>
    
    
            <script type="text/javascript" src="tiny_mce/tiny_mce_custom_popup.js"></script>
            <script type="text/javascript">
                function insert_media( element ) {
                    element = htmlspecialchars_decode( element, 'ENT_QUOTES' );
                    tinyMCE.activeEditor.execCommand('mceInsertContent', false, element);
                    return false;
                }// insert_media
    
    
                function htmlspecialchars_decode (string, quote_style) {
                    // http://kevin.vanzonneveld.net
                    // +   original by: Mirek Slugen
                    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
                    // +   bugfixed by: Mateusz "loonquawl" Zalega
                    // +      input by: ReverseSyntax
                    // +      input by: Slawomir Kaniecki
                    // +      input by: Scott Cariss
                    // +      input by: Francois
                    // +   bugfixed by: Onno Marsman
                    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
                    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
                    // +      input by: Ratheous
                    // +      input by: Mailfaker (http://www.weedem.fr/)
                    // +      reimplemented by: Brett Zamir (http://brett-zamir.me)
                    // +    bugfixed by: Brett Zamir (http://brett-zamir.me)
                    // *     example 1: htmlspecialchars_decode("<p>this -&gt; &quot;</p>", 'ENT_NOQUOTES');
                    // *     returns 1: '<p>this -> &quot;</p>'
                    // *     example 2: htmlspecialchars_decode("&amp;quot;");
                    // *     returns 2: '&quot;'
                    var optTemp = 0,
                    i = 0,
                    noquotes = false;
                    if (typeof quote_style === 'undefined') {
                        quote_style = 2;
                    }
                    string = string.toString().replace(/&lt;/g, '<').replace(/&gt;/g, '>');
                    var OPTS = {
                        'ENT_NOQUOTES': 0,
                        'ENT_HTML_QUOTE_SINGLE': 1,
                        'ENT_HTML_QUOTE_DOUBLE': 2,
                        'ENT_COMPAT': 2,
                        'ENT_QUOTES': 3,
                        'ENT_IGNORE': 4
                    };
                    if (quote_style === 0) {
                        noquotes = true;
                    }
                    if (typeof quote_style !== 'number') { // Allow for a single string or an array of string flags
                        quote_style = [].concat(quote_style);
                        for (i = 0; i < quote_style.length; i++) {
                            // Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4
                            if (OPTS[quote_style[i]] === 0) {
                                noquotes = true;
                            } else if (OPTS[quote_style[i]]) {
                                optTemp = optTemp | OPTS[quote_style[i]];
                            }
                        }
                        quote_style = optTemp;
                    }
                    if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) {
                        string = string.replace(/&#0*39;/g, "'"); // PHP doesn't currently escape if more than one 0, but it should
                        // string = string.replace(/&apos;|&#x0*27;/g, "'"); // This would also be useful here, but not a part of PHP
                    }
                    if (!noquotes) {
                        string = string.replace(/&quot;/g, '"');
                    }
                    // Put this in last place to avoid escape being double-decoded
                    string = string.replace(/&amp;/g, '&');
    
                    return string;
                }// htmlspecialchars_decode
            </script>
    
    
        </body>
    </html>
    

    jquery 1.9.0

    tinymce jQuery package 3.5.8

0 个答案:

没有答案