AJAX 模式下的 jquery 选项卡帮助 for Safari

jquery tabs in ajax mode help for safari

本文关键字:帮助 for Safari 选项 jquery 模式 AJAX      更新时间:2023-09-26

我在ajax模式下创建了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 -->

尝试使用javascript: self.history.go(-1)

出现此问题是因为 Safari 尝试调用 window.history.go(-1) 导致您的问题

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