5

如果按下浏览器的后退按钮,我有这个示例代码用于跟踪。该代码适用于计算机上的 IE、Firefox 和 Safari。当我在 Ipad 上使用 Safari 检查代码时,按下后退按钮时不会显示 .confirm 对话框。我已经在 iOS 9.3 上使用 Safari 9 进行了测试。Safari 的设置允许弹出。

我不知道如何使代码在 Ipad Safari 上运行。有人有同样的问题吗?

<html>
<head>
</head>
<body>
    <script src="jquery-3.1.0.js"></script>
    <script>
        jQuery(document).ready(function ($) {
            if (window.history && window.history.pushState) {
                window.history.pushState(null, null, $(location).attr('href'));

                $(window).on('popstate', function () {
                    $("#lblMessage").html("Onpopstate");                        

                    if (!confirm('Browse back?'))
                        window.history.pushState(null, null, $(location).attr('href'));
                    else 
                        window.history.back();
                });
            }
        });
    </script>

    <div id="lblMessage">Status
    </div>
</body>

我在这里创建了一个测试站点。

4

0 回答 0