when URL does not exists it shows the alert twice? Chrome Extension Developing
i have problem creating my extension for Chrome Browser. my problem is like the following: when the tab is updating, and the tab has completed to load the url it alerts, but when the URL does not exists (404 error, and so on) it alerts twice, why does this happens? my code:
<html>
<head>
<script type="text/javascript">
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
updatedTab = tab;
updatedTabId = tabId;
u开发者_运维知识库pdatedTabChangeInfo = 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>
sorry for my bad english, thanks for the help
Perhaps there's a "complete" notification from the server's 404 page, then a "complete" notification for Chrome's "user friendly" error page? Try turning off "Show suggestions for navigation errors" in preferences and see if there's only one alert.
精彩评论