JSFiddle - React, Tailwind, and code Playground

by Rich Costello

HTML

<a href="http://davidrhysthomas.co.uk/">Leave site</a>

JavaScript

var aElems = document.getElementsByTagName('a');

for (var i = 0, len = aElems.length; i < len; i++) {
    aElems[i].onclick = function() {
        var check = confirm("Are you sure you want to leave?");
        if (check == true) {
            return true;
        }
        else {
            return false;
        }
    };
}