I need to have a javascript function compatible with IE6 and above.
Today it works fine with Mozilla like browsers.
The problem I had is that I could not code the function to retrieve the user selection range for IE.
There is a wysiwyg editor with a popup window to enclose the text selected by the user with some html markup.
Here is the code working on Mozilla Firefox:
<script language="javascript" type="text/javascript">
function getRange() {
var userSelection = getUserSelection();
if ([login to view URL]('Microsoft') != -1) {
alert("Please use Firefox.");
}
if ([login to view URL]) {
if ([login to view URL] > 0) {
return [login to view URL](0);
}
}
}
function getUserSelection() {
var oName = [login to view URL];
if ([login to view URL]('Microsoft') == -1) {
var oEditor = [login to view URL]("idContent"+oName);
var oContentArea = [login to view URL];
var oSel = [login to view URL]();
} else {
var oEditor = [login to view URL]("idContent"+oName);
var oContentArea = [login to view URL];
var oSel = [login to view URL]();
}
return(oSel);
}
function insertLexiconEntry(lexiconEntryId) {
var span = [login to view URL]('span');
[login to view URL] = "$tooltipClassName";
[login to view URL] = "$tooltipDomId";
var range = getRange();
[login to view URL](span);
}
</script>
As you can see the getRange function does not yet care for IE. It should.
The job is to make this function return the range on IE6 and above so that it can be used by the other above functions.