js返回上一頁並重新整理
阿新 • • 發佈:2019-01-03
/點選瀏覽器上的返回按鈕,返回上一頁並重新整理
$(document).ready(function($) {
if (window.history && window.history.pushState) {
$(window).on('popstate', function() {
var hashLocation = location.hash;
var hashSplit = hashLocation.split("#!/");
var hashName = hashSplit[1 ];
if (hashName !== '') {
var hash = window.location.hash;
if (hash === '') {
self.location=document.referrer;
}
}
});
window.history.pushState(null, null, '');
}
});