Javascript,删除历史记录中的最后一项(firefox addon)

Rya*_*yan 0 javascript firefox history firefox-addon

我有一个Firefox插件,它首先显示一个警告/信息页面,告诉用户他们被重定向(chrome://localfilter/content/wait_page.html),然后将它们重定向到目的地.

一切都很好.

唯一的事情就是当他们按下后退按钮他们看到"等待页面"时,无论如何从历史记录中删除该等待页面并保留其他所有内容?或者,如果这是不可能的,用另一个可能只有徽标的页面替换那个等待页面(因为如果他们读了它们就会被重定向,没有任何反应......)

编辑:

// function to see if the banned URL is on the list, then redirect
...
window.stop(); // Totally stop the page from loading.

                            window.content.location.href = "chrome://quickfilter/content/wait_page.html";



                            this.notificationBox();
                            self.timervar = setTimeout(function ()
                            {
                                self.main.redirectToAnotherUrl();
                            }, 2505);

...


redirectToAnotherUrl: function ()
            {


                window.content.location.href = self.mafiaafireFilterUrl;
                self.timervar = setTimeout(function ()
                            {
                                self.main.notificationBox();
                            }, 2005);


            }
Run Code Online (Sandbox Code Playgroud)

更换时更改:

redirectToAnotherUrl: function ()
            {


                window.content.location.replace(self.mafiaafireFilterUrl);
                self.timervar = setTimeout(function ()
                            {
                                self.main.notificationBox();
                            }, 2005);


            }
Run Code Online (Sandbox Code Playgroud)

Wla*_*ant 7

我想最好的解决方案不是从历史记录中删除页面,而是首先不添加它.当您"重定向"到您可能正在使用的目标页面window.location.href = ...或类似的东西时.相反,您应该使用window.location.replace(...)哪个"替换"当前页面而不创建其他历史记录条目.