powered by simpleCommunicator - 2.0.59     © 2025 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / HTML, JavaScript, VBScript, CSS [игнор отключен] [закрыт для гостей] / jQuery - повторный переход back при использовании jquery.history
1 сообщений из 1, страница 1 из 1
jQuery - повторный переход back при использовании jquery.history
    #34946740
IDVsbruck
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Перекопал несколько библиотек, которые реализовывают переходы навигатора в ajax-сайте. Конечно, самая известная dojo. На втором месте jQuery - на мой взгляд, более адаптивная и простая в использовании (и есть много примеров).
В firefox все работает отлично, а в IE происходит следующее: если загрузить страницу А, потом Б и затем В, то при нажатиях на back в навигаторе обратная последовательность будет следующей (напомню - мы на В): Б - В - Б - А (с hash) - Б - А (исходная, без hash). Естественно, ссылки находятся вне меняющегося контента.

Возможно, кто-то сталкивался с этим тулкитом и подобной проблемой. В чем может быть проблема? На всякий случай привожу код:

Ссылки:
Код: plaintext
1.
2.
<a href="#page1" rel="history">Page  1 </a>
<a href="#page2" rel="history">Page  2 </a>
<a href="#page3" rel="history">Page  3 </a>
Вызывающий скрипт:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
function pageload(hash) {
	if (hash) changeContent(hash);
	else changeContent('page1');
}
$(document).ready(function() {
	$.historyInit(pageload);
	$("a[@rel='history']").click(function() {
		var hash = this.href;
		hash = hash.replace(/^.*#/, '');
		$.historyLoad(hash);
		return false;
	});
});
Обработчик (без стандартной библиотеки и выброшенным кодом для Сафари):
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
jQuery.extend({
	historyCurrentHash: undefined,
	historyCallback: undefined,
	historyInit: function(callback) {
		jQuery.historyCallback = callback;
		var current_hash = location.hash;
		jQuery.historyCurrentHash = current_hash;
		if(jQuery.browser.msie) {
			if (jQuery.historyCurrentHash == '') jQuery.historyCurrentHash = '#';
			$("body").prepend('<iframe id="jQuery_history" style="display: none;"></iframe>');
			var ihistory = $("#jQuery_history")[ 0 ];
			var iframe = ihistory.contentWindow.document;
			iframe.open();
			iframe.close();
			iframe.location.hash = current_hash;
		}
		jQuery.historyCallback(current_hash.replace(/^#/, ''));
		setInterval(jQuery.historyCheck,  100 );
	},
	historyCheck: function(){
		if(jQuery.browser.msie) {
			var ihistory = $("#jQuery_history")[ 0 ];
			var iframe = ihistory.contentDocument || ihistory.contentWindow.document;
			var current_hash = iframe.location.hash;
			if(current_hash != jQuery.historyCurrentHash) {
				location.hash = current_hash;
				jQuery.historyCurrentHash = current_hash;
				jQuery.historyCallback(current_hash.replace(/^#/, ''));
			}
		} else {
			var current_hash = location.hash;
			if(current_hash != jQuery.historyCurrentHash) {
				jQuery.historyCurrentHash = current_hash;
				jQuery.historyCallback(current_hash.replace(/^#/, ''));
			}
		}
	},
	historyLoad: function(hash) {
		var newhash;
		newhash = '#' + hash;
		location.hash = newhash;
		jQuery.historyCurrentHash = newhash;
		if(jQuery.browser.msie) {
			var ihistory = $("#jQuery_history")[ 0 ];
			var iframe = ihistory.contentWindow.document;
			iframe.open();
			iframe.close();
			iframe.location.hash = newhash;
			jQuery.historyCallback(hash);
		} else jQuery.historyCallback(hash);
	}
});
Спасибо.
...
Рейтинг: 0 / 0
1 сообщений из 1, страница 1 из 1
Форумы / HTML, JavaScript, VBScript, CSS [игнор отключен] [закрыт для гостей] / jQuery - повторный переход back при использовании jquery.history
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]