I'm looking for a little help with the code below:
The purpose of the code is to reliably get the selected object - while the code is working if the object e.g. is an image, it doesn't seem to work if the selection is some text with a link.
Thank you in advance for your help.
//var sElm = FCK.Selection.GetSelectedElement();
var sElm = FCKSelection.GetParentElement();
if (sElm != null && sElm.nodeName.toLowerCase() == 'img') { // is current cell a image ?
if(sElm.parentNode.nodeName.toLowerCase() == 'a') {
var a = sElm.parentNode;
} else {
var im = sElm;
}
} else if (sElm != null && sElm.nodeName.toLowerCase() == 'a') {
var a = sElm;
}
The purpose of the code is to reliably get the selected object - while the code is working if the object e.g. is an image, it doesn't seem to work if the selection is some text with a link.
Thank you in advance for your help.
//var sElm = FCK.Selection.GetSelectedElement();
var sElm = FCKSelection.GetParentElement();
if (sElm != null && sElm.nodeName.toLowerCase() == 'img') { // is current cell a image ?
if(sElm.parentNode.nodeName.toLowerCase() == 'a') {
var a = sElm.parentNode;
} else {
var im = sElm;
}
} else if (sElm != null && sElm.nodeName.toLowerCase() == 'a') {
var a = sElm;
}