views:

57

answers:

2

Hello Everyone,

Here is my code scenario, I display html page in webbrowser control. The content will be loaded from some RSS url dynamically (used JQuery to load the content from URL) and displayed in WB. My problem is, i have to check for the "Internet Connectivity" when a loop is completed by scrolling text. I tried using "navigator.onLine", which is working well in html page but not working when loaded into the Web browser control, it returned "true" even internet disconnected.

Thank you all in advance.

A: 

The jQuery ajax method lets you define an error callback, which should get hit if the user has dropped his connection (or for other reasons)...

$.ajax({
  url: "test.html",
  cache: false,
  success: function(html){
    $("#results").append(html);
  },
  error: function(XMLHttpRequest, textStatus, errorThrown){
    alert("oh crap, an error: " + textStatus);
  }
});

For more info: http://api.jquery.com/jQuery.ajax/

Mike Ruhlin
Mike, thanks for your reply. I tried above solution, but always error function gets called even the connection is up(checked for www.google.com and yahoo too).
N Chary
post the code you're using?
Mike Ruhlin
A: 

Simply test for two reliable websites e. g. www.google.com and www.yahoo.com - when at least one of them is up then consider the PC online.

MikeK