vmars316 5 Posted November 12, 2020 Report Share Posted November 12, 2020 It took me a while , but here's the code; <!DOCTYPE html> <html> <head> <title> AddEventListener-For-A-Tag-Stop-Navigation </title> <script> function CreateJsListener() { document.querySelector('a').addEventListener('click', function(event) {Redirect(event) } ) } ; </script> </head> <body onload="CreateJsListener()"> <a href="https://www.google.com"> https://www.google.com </a> <script> var timesThru = 0 ; function Redirect(event) { event.preventDefault() ; window.open("NOT-A-SafeSite.html"); timesThru = timesThru + 1 ; } </script> </body> </html> <!DOCTYPE html> <html> <head> <title> NOT-A-SafeSite.html </title> </head> <body> <h4> The Link you clicked on is <span style="color: red">UNSAFE !</span> ....Navigation CANCELED. </h4> </body> </html> Thank you Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.