这是我的代码方案, 我在webbrowser控件中显示html页面。内容将从一些RSS url动态加载(使用JQuery从URL加载内容)并在WB中显示。我的问题是,当通过滚动文本完成循环时,我必须检查“Internet连接”。我尝试使用“navigator.onLine”,它在html页面中运行良好但在加载到Web浏览器控件时无法正常工作,即使互联网断开连接也返回“true”。
答案 0 :(得分:0)
jQuery ajax方法允许您定义错误回调,如果用户已断开连接(或出于其他原因),该错误回调应该被点击...
$.ajax({
url: "test.html",
cache: false,
success: function(html){
$("#results").append(html);
},
error: function(XMLHttpRequest, textStatus, errorThrown){
alert("oh crap, an error: " + textStatus);
}
});
答案 1 :(得分:0)
只需测试两个可靠的网站e。 G。 www.google.com和www.yahoo.com - 当至少其中一个出现时,请考虑在线使用PC。