Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <head> <base id="myBase" href="https://www.w3schools.com/jsref/"> </head> <body> <p>Click the button to set the value of the target attribute of ALL links on a page to "_blank".</p> <p><a href="https://www.w3schools.com/">W3Schools</a></p> <p><a href="https://www.w3schools.com/">W3Schools</a></p> <p><b>Note:</b> Try the links before and after you have clicked the button!</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myBase").target = "_blank"; document.getElementById("demo").innerHTML = "The value of the target attribute was set."; } </script> </body> </html>