检查JavaScript中的网络连接

时间:2013-10-17 10:32:04

标签: javascript mobile

如果用户使用的是数据套餐或Wi-Fi,我可以在移动网页上办理登机手续吗?有没有办法做到这一点,即使使用专有API?

1 个答案:

答案 0 :(得分:0)

可以像这样访问

(navigator.connection || navigator.mozConnection || navigator.webkitConnection).type

其中type可以是“cellular”,“bluetooth”,“ethernet”,“wifi”,“wimax”,“other”,“none”,“mixed”,“unknown”之一(参见{{3}更多细节)。

不幸的是https://w3c.github.io/netinfo/#the-connectiontype-enum非常糟糕。它是support

相关问题