pushState()正在驳回'记住密码'对话

pushState() dismissing 'remember password' dialog

本文关键字:对话 密码 pushState      更新时间:2023-09-26

我想我有一个有趣的问题,经过几天的思考和研究,我一直无法找到解决方案。

我正在编写一个受phpMyAdmin启发的web应用程序,因此它使用框架来控制内容的放置。因此,访问的任何url都将始终是index.php。除非我使用历史API的pushState()方法来更改url以反映框架中访问的页面。

然而,问题来自于这种方法;登录后,用户将从login.html重定向到index.php,在一瞬间,chrome询问是否希望我记住密码。。当访问触发CCD_ 4方法时,该小条消失。我不希望应用程序继续提交这种行为。我希望用户能够存储他们的密码,如果他们愿意的话(我还没有进入cookie,我在这方面还很陌生)。

我试着围绕访问的最后一页进行检查,但由于我在这方面的经验,结果没有成功。。因此,如果有任何关于如何解决问题的想法,请更多地关注这一点。

如果它有帮助的话,我目前触发它的代码是.

$(window).on('load', function (){
    window.parent.history.pushState(null, "index.php", "index.php");
});

到目前为止,这种行为只发生在Chrome上。Firefox和IE的行为与预期一致。

以避免初始推送状态

(function($) {
  var firstLoad=true;
  $(window).on('load', function (){
    if (firstLoad!==true)
      window.parent.history.pushState(null, "index.php", "index.php");
    firstLoad=false;
  });
})(jQuery);

尝试这个

(function($) { 
    var isFirst = true;

    $(window).on('load', function (evt){
        if(isFirst && wasLastPage('index.html')) return;
        isFirst = false;
        window.parent.history.pushState(null, "index.php", "index.php");
    });
    function wasLastPage(pageName){
        //document.referrer only works in non IE
        var lastPage = (document.referrer)? document.referrer : '';
        return (lastPage.indexOf(pageName) === lastPage.length - pageName.length);
    }
});