Using "beforeunload" with live redirects

Maybe you could assign a class to link and then add event listener to all classes on the page?