G
G
genesis11112019-05-20 20:50:08
JavaScript
genesis1111, 2019-05-20 20:50:08

How to close tab chrome extension?

Hello!
I open a tab with an extension.

chrome.tabs.create({
         url: 'http://kjasdnfjsdf3223.ru',
         active: true,
      });

Since the site kjasdnfjsdf3223.ru does not exist, it will not load.
how to detect it and close the tab?
If the site exists and has loaded, leave it as it is.
Separately, I know what the tab closing function looks like. But I can't figure out how to identify non-existent sites

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Shohruh Shaimardonov, 2019-05-20
@genezis1111

See what response the site comes with. Successfully received site should be with 200m code. The most popular is 404, and so on. In your case, 500 codes are more suitable

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question