javascript - how to get url in html , document.referrer is empty -


please current url page called ? wrong ?, becaz alert comes empty.

<html> <head> <script>  function check() { alert(document.referrer); } </script> </head> <body onload="check()">  </body> </html> 

according mdn document.referrer

the value empty string if user navigated page directly (not through link, but, example, via bookmark).

you if want current page url can use

window.location.href 

Comments