1. 程式人生 > >js獲取來源url(上個頁面的地址)

js獲取來源url(上個頁面的地址)

//獲取來源url:ref
var ref = ''; 
if (document.referrer.length > 0) { 
  ref = document.referrer; 

try { 
  if (ref.length == 0 && opener.location.href.length > 0) { 
   ref = opener.location.href; 
  } 

} catch (e) {}    

當前頁面地址:window.location.href