Link selection in FireFox

Hi everyone,

I have this small code below to see if the text selected is a link or not. It works fine but in Firefox I get a null on a link if it is selected from RIGHT to LEFT.
Who can help me out?


function getInfo()
{
if (document.selection && document.selection.createRange) {

[INDENT]var selection  = textEditor.document.selection.createRange();
var tag  = selection.parentElement().tagName;
var link  = selection.parentElement().getAttribute("href");[/INDENT]
			
} else if (window.getSelection) {

[INDENT]var selection = textEditor.window.getSelection(); 
var node = selection.anchorNode;
var tag = node.parentNode.tagName;
var link = node.parentNode.getAttribute("href");[/INDENT]	
}
		
alert('Tagname='+tag+' Link='+link+'');	
}