Просмотр исходного кода

BugFix: #119 Tabs(a[data-toggle="tab"][href="#..."]) push browser history twice

Yuki Takei 8 лет назад
Родитель
Сommit
840a5582b2
1 измененных файлов с 7 добавлено и 3 удалено
  1. 7 3
      resource/js/legacy/crowi.js

+ 7 - 3
resource/js/legacy/crowi.js

@@ -757,13 +757,17 @@ $(function() {
   // hash handling
   if (isSavedStatesOfTabChanges) {
     $('a[data-toggle="tab"][href="#revision-history"]').on('show.bs.tab', function() {
-      window.history.pushState('', 'History', '#revision-history');
+      window.location.hash = '#revision-history';
+      window.history.replaceState('', 'History', '#revision-history');
     });
     $('a[data-toggle="tab"][href="#edit-form"]').on('show.bs.tab', function() {
-      window.history.pushState('', 'Edit', '#edit-form');
+      window.location.hash = '#edit-form';
+      window.history.replaceState('', 'Edit', '#edit-form');
     });
     $('a[data-toggle="tab"][href="#revision-body"]').on('show.bs.tab', function() {
-      window.history.pushState('', '',  location.href.replace(location.hash, ''));
+      // couln't solve https://github.com/weseek/crowi-plus/issues/119 completely -- 2017.07.03 Yuki Takei
+      window.location.hash = '';
+      window.history.replaceState('', '', location.href.replace(location.hash, ''));
     });
   }
   else {