I am importing a text document named test.txt using JavaScript and sending each line into an array called linesArr. I am successful doing that but I need to turn the array indexes into a clickable hyperlink using JavaScript only. (I'm using Animate CC but JavaScript solutions work the same in Animate CC.
My text file reads (each on separate lines)
https://www.google.com
https://www.facebook.com
https://www.amazon.com
JavaScript
that = this;
function getData(){
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
var lines = xmlhttp.responseText;
intoArray(lines);
}
}
xmlhttp.open("GET", "test.txt", true);
xmlhttp.send();
}
function intoArray (lines) {
var lineArr = lines.split('\n');
alert("lineArr[2]");
}
getData();
that.button.addEventListener("click", fl_ClickToGoToWebPage);
function fl_ClickToGoToWebPage() {
window.open(lineArr[1], "_blank");
}