2011-05-06 33 views
1

我在Ajax模式下創建了jQuery選項卡。Ajax模式幫助Safari瀏覽器的jquery選項卡

在我的其中一個選項卡中,我有一個使用javascript: history.go(-1)的應用程序後退按鈕。

一切工作正常在IE瀏覽器。當我點擊我的後退按鈕時,它會將我帶到iFrame中的初始頁面。但是當我在Safari中嘗試相同的功能時,按鈕會將我帶到我的主頁。我也意識到Safari的瀏覽器按鈕可以做同樣的事情,而IE的瀏覽器按鈕可以完美地工作。

我無法理解我的頁面做這個的原因。任何想法來解決它?

<meta charset="utf-8"> 
    <script> 
    $(function() { 
     $("#tabs").tabs({ 
      ajaxOptions: { 
       error: function(xhr, status, index, anchor) { 
        $(anchor.hash).html(
         "Couldn't load this tab. We'll try to fix this as soon as possible. " + 
         "If this wouldn't be a demo."); 
       } 
      } 
     }); 
    }); 
    </script> 

<div class="demo"> 

<div id="tabs"> 
    <ul> 
     <li><a href="#tabs-1">Preloaded</a></li> 
     <li><a href="ajax/content1.html">Tab 1</a></li> 
     <li><a href="ajax/content2.html">Tab 2</a></li> 
     <li><a href="ajax/content3-slow.php">Tab 3 (slow)</a></li> 
     <li><a href="ajax/content4-broken.php">Tab 4 (broken)</a></li> 
    </ul> 
    <div id="tabs-1"> 
     <p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.</p> 
    </div> 
</div> 

</div><!-- End demo --> 



<div class="demo-description"> 
<p>Fetch external content via Ajax for the tabs by setting an href value in the tab links. While the Ajax request is waiting for a response, the tab label changes to say "Loading...", then returns to the normal label once loaded.</p> 
<p>Tabs 3 and 4 demonstrate slow-loading and broken AJAX tabs, and how to handle serverside errors in those cases. Note: These two require a webserver to interpret PHP. They won't work from the filesystem.</p> 
</div><!-- End demo-description --> 

回答

1

嘗試使用javascript: self.history.go(-1)

出現問題是因爲Safari瀏覽器試圖調用window.history.go(-1),導致您的問題

延伸閱讀:http://benalman.com/news/2009/12/webkit-bug-hash-history-iframe/

+0

好吧,當我點擊我的後退按鈕,因爲我第一次點擊它似乎沒有反應,然後我再次點擊它將我帶到我的主頁。 – bobo 2011-05-06 20:46:11

+0

我意識到的另一件事是當我使用safari打開我的應用程序時,我的後退按鈕起作用。但標籤界面似乎是問題。有任何想法嗎? – bobo 2011-05-06 20:56:21

+0

如何在iframe中打開您的應用程序,檢查問題是iframe還是製表符? 如果問題是一個iframe,請再次嘗試我的解決方案 – 2011-05-06 23:18:02