请帮助获取调用此页面的当前URL?这有什么问题?,因为警报空洞.
<html>
<head>
<script>
function check()
{
alert(document.referrer);
}
</script>
</head>
<body onload="check()">
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
据MDN称 document.referrer
如果用户直接导航到页面(不是通过链接,而是通过书签),则该值为空字符串.
如果你想获得当前页面的网址,那么你可以使用
window.location.href
Run Code Online (Sandbox Code Playgroud)