Google chrome extension 当URL不存在时,它会显示两次警报?铬延伸显影

Google chrome extension 当URL不存在时,它会显示两次警报?铬延伸显影,google-chrome-extension,Google Chrome Extension,我在为Chrome浏览器创建扩展时遇到问题。 我的问题如下: 当选项卡正在更新,并且选项卡已完成加载其发出警报的url时,但当url不存在(404错误等)时,它会发出两次警报,为什么会发生这种情况? 我的代码: chrome.tabs.onUpdate.addListener(函数(tabId、changeInfo、tab){ updatedab=tab; updatedabid=tabId; updatedTabChangeInfo=变更信息; 如果(changeInfo.status==“

我在为Chrome浏览器创建扩展时遇到问题。 我的问题如下: 当选项卡正在更新,并且选项卡已完成加载其发出警报的url时,但当url不存在(404错误等)时,它会发出两次警报,为什么会发生这种情况? 我的代码:


chrome.tabs.onUpdate.addListener(函数(tabId、changeInfo、tab){
updatedab=tab;
updatedabid=tabId;
updatedTabChangeInfo=变更信息;
如果(changeInfo.status==“完成”)
{
如果((updatedab.url.indexOf(“http:/”))=-1||
updatedab.url.indexOf(“https:/”)!=-1||
updatedab.url.indexOf(“ftp://”!=-1))//检查当前url是否不是选项窗口之一,也不是chorme的基本页面之一
{
警报(updateTab.url);
}
}
});
对不起,我的英语不好, 感谢您的帮助

也许服务器的404页面会发出“完整”通知,然后Chrome的“用户友好”错误页面会发出“完整”通知?尝试关闭“首选项”中的“显示导航错误建议”,查看是否只有一个警报

<html>
<head>
<script type="text/javascript">
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
    updatedTab = tab;
    updatedTabId = tabId;
    updatedTabChangeInfo = changeInfo;

    if (changeInfo.status == "complete")
    {
        if ((updatedTab.url.indexOf("http://") != -1 ||
            updatedTab.url.indexOf("https://") != -1 ||
            updatedTab.url.indexOf("ftp://") != -1)) // check that the current url isn't one of the options window and isnt one of chorme's basic pages
        {
            alert(updatedTab.url);
        }
    }
});
</script>
</head>
<body>
</body>
</html>