美文网首页
JS 检查网络

JS 检查网络

作者: 草帽lufei | 来源:发表于2019-08-26 20:49 被阅读0次

JS检查网络是否可以使用谷歌搜索

使用 Image 加载一张Google官方的 LOGO

var img = new Image(); 
img.addEventListener('load', function() {
  console.log('Google is accessible')
}, false);
img.src = 'https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png';

注意!!!
由于图片在浏览器中存在缓存问题,开发阶段需要每次需要清理缓存,关闭浏览器才能正确检查

相关文章

网友评论

      本文标题:JS 检查网络

      本文链接:https://www.haomeiwen.com/subject/wwtkrctx.html