Solved

How to detect internet connection with jQuery?

Posted on 2008-10-31
5
2,023 Views
Last Modified: 2012-05-05
I am using web services on a web site that can also run in a local machine. Is there any standard way in form of an elegant jQuery script to detect whether the internet connection is available?
0
Comment
Question by:koleto115
  • 3
  • 2
5 Comments
 
LVL 18

Expert Comment

by:wilq32
Comment Utility
You can try by loading image from internet:

var connection=false;
var image=new Image();
image.src="http://someimageonthenet.com/jpg.jpg";
image.onload=function () {  connection=true; }
0
 

Author Comment

by:koleto115
Comment Utility
What will happen when the url of the image is change or removed?
Furthermore this is not jQuery call. There should be kind of utility function not related to resource on the internet that can be changed ....
0
 
LVL 18

Expert Comment

by:wilq32
Comment Utility
Nope there is not... jQuery is only a Javscript libary - it iteslf cannot do what javscript cant too. This not have to be image.. but anything that is internet and you sure that it will be there... If someone other got better idea... Then i really curious :)
0
 

Author Comment

by:koleto115
Comment Utility
There is utilities for detecting the browser, there should be something ...
I know that Ajax makes only http request but ... I am curious too ... ;)
0
 
LVL 18

Accepted Solution

by:
wilq32 earned 125 total points
Comment Utility
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now