Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Get Current URL in JavaScript</title> </head> <body> <script> function getURL() { alert("The URL of this page is: " + window.location.href); } </script> <button type="button" onclick="getURL();">Get Page URL</button> </body> </html>