Javascript 从嵌入的JS脚本获取页面url

Javascript 从嵌入的JS脚本获取页面url,javascript,Javascript,我有一个调用JS文件的HTML页面。在这个JS文件中,我需要知道HTML页面的URL是什么 到目前为止,我有这个 HTML- <!doctype html> <html> <head> <title>Untitled</title> </head> <body> <script src="js/jquery.js"></script> <script src="js/ma

我有一个调用JS文件的HTML页面。在这个JS文件中,我需要知道HTML页面的URL是什么

到目前为止,我有这个

HTML-

<!doctype html>
<html>
 <head>
  <title>Untitled</title>
 </head>
<body>
 <script src="js/jquery.js"></script>
 <script src="js/main.js"></script>
</body>
</html>
我以为document.referer会返回html页面的URL。但是,它在控制台中返回一个空行

任何帮助都会很好。谢谢你试试这个

console.log(document.URL);

因为我了解到它在firefox的某些版本中不起作用,所以使用location.href获取页面的url

jQuery(document).ready(function(){

       jQuery("#url1").html(location.href);   

});

脚本被添加到标签Best practiceNope中,只是结束正文标签也是一个很好的实践
console.log(window.location.href); 
jQuery(document).ready(function(){

       jQuery("#url1").html(location.href);   

});