function InsertIntoTextArea() { alert("Hello from IITA"); // var KeyPress = window.AppInventor.getWebViewString(); // This might make referecing more efficient, but meantime long-winded ByID.. // var textstring = document.getElementById("abc").value; // Get the length of the string in textarea "abc" // var length = document.getElementById("abc").length; // .selectionStart returns the cursor position // var position = document.getElementById("abc").selectionStart; // Split the text into before and after cursor position // var before = document.getElementById("abc").substring(0, position); // var after = document.getElementById("abc").substring(position, lenght); // Reassemble textarea with 'AIKeyPress inserted // document.getElementById("abc").value = before + KeyPress + after; // Return some info to see what happened - or not! // alert("Processed: " + KeyPress + " at " + position); }