I have a page that has some functions that I would like to load when the page gets loaded .. Currently the function is called only when a button is clicked, I would also like this to loaded on page load / refresh
function LOADMEONSTARTUP() {
var reader = new XMLHttpRequest() || new ActiveXObject('MSXML2.XMLHTTP');
reader.open('get', 'log.txt', true);
reader.onreadystatechange = function () {
if (reader.readyState == 4 && reader.status == 200) {
displayContents1(reader.responseText);
}
};
reader.send();
}
function displayContents1(content) {
var wanted = 'apples';
var words = content.split(/\s/);
var found = [];
words.forEach(function (word, index) {
if (word === wanted && words[index + 1]) {
found.push(words[index + 1]);
}
});
console.log('found:', found);
var el = document.getElementById('here1');
el.innerHTML = found.length ? found.join('<br/>') : 'nothing found';
}