document.URL:返回当前文档完整的URL
可以通过 alert(document.URL) 来试一下
docuemnt.referrer:返回的是载入当前页面的url(返回载入当前文档的文档的 URL)
<button onclick = "window.open("look.html")>登录<button>
let url = document.referrer
if(url == "") {
document.write("请先登录,2秒后跳回登陆页面")
setTimeOut("location.href = 'login.html' ",2000)
}else{
document.write("欢迎页面!")
}