JavaScript中document.referrer的用法详解
document.referrer简介document.referrer返回当前文档的引用来源URL,即用户打开当前页面时之前的页面。它用于跟踪流量来源、防止跨域攻击和分析用户行为。用法:constreferrer=document.referrer;兼容:所有现代浏览器。安全注意事项:注意隐私和跨域攻击的风险。替代方案:window.location.href、history.back()、PerformanceAPI。最佳实践:告知用户、限制使用、保护隐私、防止跨域攻击。