function doesConnectionExist() {
    var xhr = new XMLHttpRequest();
    var file = "https://www.emretalu.net";
    var randomNum = Math.round(Math.random() * 10000);
 
    xhr.open('HEAD', file + "?rand=" + randomNum, true);
    xhr.send();
     
    xhr.addEventListener("readystatechange", processRequest, false);
 
    function processRequest(e) {
		if (xhr.readyState == 4) {
			if (xhr.status >= 200 && xhr.status < 304) {
				alert("connection exists!");
			} else {
				alert("connection doesn't exist!");
			}
		}
    }
}