检查是否连接到网络; jQuery的 [英] Check if connected to a network; jQuery
问题描述
我已经通过StackOverflow进行了搜索,并且已经看到了有关如何执行此操作的各种主题,但没有涉及到我的特定情况。我正在编写一个移动应用程序(使用HTML5,CSS,jQuery)。它最终将成为一个独立的应用程序,它将包含所有所需文件的本地副本。在我的一个页面上我有一个提交表单,并且由于用户无法在离线状态下提交表单,我希望该页面被重定向到一个自定义的404页面。
我只是在寻找是否有办法在jQuery中实现这一点,因为我还没有发现任何东西。
谢谢
你可以使用
if(navigator.onLine){
//我在线提交表单。
}
I have searched through StackOverflow and have seen various topics on how to do this, but nothing that really pertains to my particular situation. I am writing (for a class) a mobile "application" (using HTML5, CSS, jQuery). It will end up being a stand alone "app", something that will contain a local copy of all the needed files. On one of my pages I have a submit form, and since the user can't submit the form if they are offline, I would like the page to be redirected to a custom 404 page.
I was just searching to see if there was a way to accomplish this in jQuery, as I haven't really found anything yet.
Thanks
You could use
if (navigator.onLine) {
// I'm online so submit the form.
}
这篇关于检查是否连接到网络; jQuery的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!