I need to make sure that when the user clicks OK in a JavaScript alert window, the browser moves to a different URL. Is this possible?
If it is for accessibility and you want to listen to every link on the page and than check if you are leaving the current site to another domain, check out what I wrote, expanding on Joe's answer
$('a').on('click', function() {
if ( this.host !== window.location.host ) {
if ( window.confirm('Really go to another page?') ) {
// They clicked Yes
console.log('you chose to leave. bye.');
}
else {
// They clicked no
console.log('you chose to stay here.');
return false
}
}
});