禁用瀏覽器回退按鈕

其他瀏覽器的禁用回退按鈕

$(function(){
        if (window.history && window.history.pushState) {
            $(window).on('popstate', function () {
                window.history.pushState('forward', null, '');
                window.history.forward(1);
            });
        }
        window.history.pushState('forward', null, '');
        window.history.forward(1);
    })

關於ie8,ie8是沒有這個功能的,只能通過url來實現

	// 直接使用url去替換回退
	var hash_current = "#";
	var hash_last = "#";
		window.location.hash = hash_current;
		window.location.hash = hash_last;
		window.onhashchange = function () {
		window.location.hash = hash_current;
	};
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章