selection range issue in IE9
I have the following JavaScript code works in IE6, IE7 and IE8. However, the parentEleme开发者_运维知识库nt() and commonParentElement() are not defined in IE9. Would anyone know how to workaround it?
if (document.selection)
{
var sel = document.selection;
var rng = sel.createRange();
if (rng)
{
if ("Control" == sel.type && typeof rng.commonParentElement != "undefined")
{
targetElement = rng.commonParentElement(); // undefined in IE9
}
else if (typeof rng.parentElement != "undefined")
{
targetElement = rng.parentElement(); // undefined in IE9
}
}
}
精彩评论