taoguan / jwysiwyg

Automatically exported from code.google.com/p/jwysiwyg
0 stars 0 forks source link

Creating link on an image gives js-error #91

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Open editor.
2. Insert image
3. Select image
4. Create link

What is the expected output?
Popup with link-dialog.

What do you see instead?
Nothing. Gives JS error (length not defined)

What version of the product are you using? 
0.5

On what operating system?
reproduced on IE8 and IE7

Please provide any additional information below.
Sollution: 

Add if-else statement at line 220 to check if selection exists: 

                    if ( selection.length > 0 )
                    {
                        if ( $.browser.msie )
                            this.editorDoc.execCommand('createLink', true, 
null);
                        else
                        {
                            var szURL = prompt('URL', 'http://');

                            if ( szURL && szURL.length > 0 )
                            {
                                this.editorDoc.execCommand('unlink', 
false, []);
                                this.editorDoc.execCommand('createLink', 
false, szURL);
                            }
                        }
                    }
                    else if ( this.options.messages.nonSelection )
                        alert(this.options.messages.nonSelection);

Original issue reported on code.google.com by c...@mindyourguest.nl on 26 Mar 2009 at 9:55

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Sollution will be:

if ( selection ) 
{
    if ( selection.length > 0 )
    {
        if ( $.browser.msie )
            this.editorDoc.execCommand('createLink', true, null);
        else
        {
            var szURL = prompt('URL', 'http://');

            if ( szURL && szURL.length > 0 )
            {
                this.editorDoc.execCommand('unlink', false, []);
                this.editorDoc.execCommand('createLink', false, 
szURL);
            }
        }
    }
    else if ( this.options.messages.nonSelection )
        alert(this.options.messages.nonSelection);
}
else if ( this.options.messages.nonSelection )
{
        alert(this.options.messages.nonSelection);
}

Original comment by c...@mindyourguest.nl on 26 Mar 2009 at 9:56

GoogleCodeExporter commented 8 years ago
Thanks, landed in 
http://github.com/akzhan/jwysiwyg/commit/34cd47fb3cf43958a19d9b1dca0caaaadddb4ba
b

Original comment by akzhan.a...@gmail.com on 27 Jun 2010 at 10:58