Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery Get Current Page URL</title> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ var pageURL = $(location).attr("href"); alert(pageURL); }); }); </script> </head> <body> <button type="button">Get URL</button> </body> </html>