在JavaScript中獲得HTTP請求的Referer
Js中獲取HTTP請求的上一次訪問來源地址
JavaScript window.location對象
/** * 獲取HTTP請求的Referer * @ishost 布爾類型 Referer為空時是否返回Host(網(wǎng)站首頁地址) */ function get_http_referer(ishost) { if (ishost === undefined) { ishost = true; } if (document.referrer) { return document.referrer; } else { if (ishost) { return window.location.protocol "http://" window.location.host; } else { return ""; } } }
原文鏈接:在JavaScript中獲得HTTP請求的Referer