Here's my code:
function moremagic()
{
var txt = '';
if (window.getSelection)
{
txt = window.getSelection();
}
else if (document.getSelection)
{
txt = document.getSelection();
}
else if (document.selection)
{
txt = document.selection.createRange().text;
}
else return;
if(txt=="" || txt==" "){
alert("No Text Selected");
return;}
var start = txt.anchorOffset;
var countstring = txt.toString();
alert(txt.anchorNode);
var end = txt.anchorOffset+countstring.length;
var type = prompt("Annotation Type: ");
if(type=="lp-token"){
var description = prompt("Lisp Statement: ");}
else if(type=="section-head-annotation"){
var description = "Section Head";}
else if(type=="list-item-annotation"){
var description = "list-element";}
else if(type=="sentence-annotation"){}
else {var description = prompt("Description: ");}
Arraystring = Arraystring+"#"+type+"#"+description+"#"+start+"#"+end;
alert(Arraystring);
var custom = document.getElementById("custom");
custom.value=Arraystring;
}
It generates a textnode object from text highlighted by the cursor but this function is called many different times and for each different highlight the anchorNode changes. I need the anchorNode to be a constant for all of the created textnode objects. Is there any way that the anchorNode of a textobject can be changed? Thank you!