<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>new-tab option</title> </head> <body> <div> <label><input type="checkbox" oninput="set_new_tab(this.checked)">new tab</label> </div> <a href="https://microsoft.com">microsoft.com</a> <a href="https://google.com" target="_blank">google.com</a> <a href="https://ibm.com" target="_self">ibm.com</a> <script> function set_new_tab(new_tab){ //alert(new_tab) for(var link of document.querySelectorAll('a:not([target]), a[data-target_set]')){ link.target=new_tab?'_blank':'' link.dataset.target_set=true } } </script> <script src="/web/show-source.js"></script> </body> </html>