jquery.wysiwyg.js - Fix to Problem with assigning URL to image in Internet Explorer
The jquery.wysiwyg.js plugin is working fine in FireFox. But when it is loaded in Internet Explorer, we are not able to set a link for the image. It shows an error "SCRIPT5007: Unable to get value of the property 'length': object is null or undefined jquery.wysiwyg.js, line 1 character 3646".
I went into the code of jquery.wysiwyg.js and found that for IE, the function $.fn.documentSelection is returning the selected content. If the content is text, it works fine. But if it is image we have the problem. So I edited the code of the source file to fix this, eventhough I need to test this extensively to confirm.
$.fn.documentSelection = function()
{
var element = this[0];
if (element.contentWindow.document.selection)
if (String(element.contentWindow.document.selection.createRange().text) == 'undefined') {
return element.contentWindow.document.selection.createRange();
}
else {
return element.contentWindow.document.selection.createRange().text;
}
else
return element.contentWindow.getSelection().toString();
};
I went into the code of jquery.wysiwyg.js and found that for IE, the function $.fn.documentSelection is returning the selected content. If the content is text, it works fine. But if it is image we have the problem. So I edited the code of the source file to fix this, eventhough I need to test this extensively to confirm.
$.fn.documentSelection = function()
{
var element = this[0];
if (element.contentWindow.document.selection)
if (String(element.contentWindow.document.selection.createRange().text) == 'undefined') {
return element.contentWindow.document.selection.createRange();
}
else {
return element.contentWindow.document.selection.createRange().text;
}
else
return element.contentWindow.getSelection().toString();
};
Comments