<!DOCTYPE html> <html> <body> <h2>The href Property</h2> <p>Click the button to set the href value to https://www.workingcode.in/developer-forum/.</p> <button onclick="myFunction()">Take me to https://www.workingcode.in</button> <script> function myFunction() { location.href = "https://www.workingcode.in/developer-forum/"; } </script> </body> </html>
Output:
href Method Javascript
Expert Edited question July 18, 2023