Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在开发一个应用程序,它使用服务工作者来缓存来自特定端点的 HTTP 请求。这些请求应该使用后台同步发送到服务器。我知道某些浏览器不受支持,但我想警告我的用户此功能将不可用。为此,我需要某种方式来确定浏览器是否支持后台同步。
if ('serviceWorker' in navigator && 'SyncManager' in window) { // service worker stuffs here } else { console.error('Background sync not supported'); }