1. 程式人生 > >window.location.replace和window.location.href區別

window.location.replace和window.location.href區別

比如有3個頁面:跳轉關係為  a > b > c;

1:b > c 是通過window.location.replace("..xx/c.xx")   此時b頁面的url會被c頁面代替,並且點選後退按鈕時會回退到a頁面(最開始的頁面);

2:b > c 是通過window.location.href("..xx/c.xx")    此時b頁面的路徑會被c頁面代替,但是點選回按鈕後頁面回退的是b頁面;

 

二者的區別:回退時返回的頁面不一致;