- Code: Select all
let values = this.getTheWord();
let start = values[0]; //start is immediately in front of the word.
let myWord = values[1];
start = start * 1;
console.log(start + " " + myWord);
tbfunction_caretPosition("myText2", start);
const start2 = ('0000' + start).slice(-5);
const myID = "w" + start2;
const newWord = '<span id=' + String.fromCharCode(34) + myID + String.fromCharCode(34) + ' onclick= "top.relay(' + String.fromCharCode(39) + myID + String.fromCharCode(39) + ')" class="blueWords"> ' + myWord + '</span>';
start += this.offset;
let htm = this.obj2.innerHTML
let end = htm.length;
let front = htm.substring(0, start);
let back = htm.substring(start, end);
htm = front + "ˆ" + back; // ansi 136 - standalone circonflex accent not used in any languages that I know of but I remove all instances just in case and replace them with a space.
let oldWord = "ˆ" + myWord
htm = tbfunction_pgReplace(oldWord, newWord, htm);
this.obj2.innerHTML = htm;
this.offset += 73; //No of characters added. This is fixed.
Is there a way I could get the real position in the innerHTML instead of the apparent visible position?