开发者

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
           }
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜