简体   繁体   中英

Webbrowser control , Detect internet connection

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.

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM