Like add an event listener to the xmlhttp object page and add the url to an array,so I can save all the url's,it shows up in the network tab of the web inspector,so if the page makes a http get,I have the url added to an array
thanks
Like add an event listener to the xmlhttp object page and add the url to an array,so I can save all the url's,it shows up in the network tab of the web inspector,so if the page makes a http get,I have the url added to an array
thanks
You could do something like this:
HTML
<input type="text" id="url">
<button id="submit">submit</button>
JS
var urlInput = document.getElementById("url");
document.getElementById("submit").addEventListener("click", function(){
request(urlInput.value);
urlInput.value = null;
});
var urls = [];
function urlPush(u){
urls.push(u);
console.log(urls);
}
function request(dataURL) {
var xmlhttp = new XMLHttpRequest();
var url = dataURL;
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
urlPush(url);
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
With this you insert URL in input and on success URL is pushed to array which you can see in console on submit.
I created similar functions for some of my projects so here you can test and inspect extended code for it with additional array of URLs for what you need.