How to get the URL of the current web page in JavaScript

2 Answers

0 votes
document.write("URL of the current web page is: " + window.location.href);            
            
/*
run:
  
URL of the current web page is: http://localhost:8080/test.html
  
*/

 



answered Jul 13, 2015 by avibootz
edited Jul 13, 2015 by avibootz
0 votes
document.write("URL of the current web page is: " + document.URL);            
            
/*
run:
  
URL of the current web page is: http://localhost:8080/test.html
  
*/

 



answered Jul 13, 2015 by avibootz
...