[SOLVED] Get selection range "parent node" in IE
Posted: Mon Mar 07, 2005 8:40 am
I have a problem with cross browser combatibility which I have not found a solution to...
For Netscape/Mozilla you can get the "parent node" of a selection using the following code...
Unfortunately IE6 does not support/allow the rng.commonAncestorContainer command and of course getting the selection is different.
Does anyone have any ideas on how to get the "common Ancestor Node" of the Range using IE 6 ?
For Netscape/Mozilla you can get the "parent node" of a selection using the following code...
Code: Select all
var selection = window.getSelection();
rng = selection.getRangeAt(selection.rangeCount - 1).cloneRange(); parentnode=rng.commonAncestorContainer;Code: Select all
var selection = document.selection;
if (selection != null) { rng = selection.createRange(); }
// Need the equivalent to rng.commonAncestorContainer Here