如何在不使用导航器的情况下检测我的互联网 [英] How detect my internet connection without using navigator

查看:64
本文介绍了如何在不使用导航器的情况下检测我的互联网的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要检测我的脚本加载时是否存在Internet连接,我使用navigator.online它说连接就在那里如果局域网中的PC并且能够连接到互联网,以及我的Gmap js文件的路径应根据连接设置加载在线和离线设置我最初试过



$(文件).ready(function() {

$ .ajax({

url:'http://in.yahoo.com/',

成功:功能(数据) ){

alert('Connection。');

},

错误:函数(数据){

提醒('没有连接。');

}

});

});



但这也不起作用。



我得到的错误就像XMLHttpRequest无法加载http://in.yahoo.com/。 Access-Control-Allow-Origin不允许使用origin http:// localhost:40624。



我添加了



protected void Application_BeginRequest(object sender,EventArgs e)

{

HttpContext.Current.Response.AddHeader(Access-Control-Allow-Origin,*);

}
$我的Global.asax文件中的b $ b



PLs建议我几乎要花一天时间搜索,请帮助我

推荐答案

(document).ready(function(){
(document).ready(function () {


.ajax( {

url:'http://in.yahoo.com/',

成功:功能(数据){

alert('连接。');

},

错误:功能(数据){

alert('无连接。');

}

});

});



但这也不行ing。



我得到的错误就像XMLHttpRequest无法加载http://in.yahoo.com/。 Access-Control-Allow-Origin不允许使用origin http:// localhost:40624。



我添加了



protected void Application_BeginRequest(object sender,EventArgs e)

{

HttpContext.Current.Response.AddHeader(Access-Control-Allow-Origin,*);

}
$我的Global.asax文件中的b $ b



PLs建议我几乎要花一天时间搜索,请帮助我


参考文章

测试互联网连接 [ ^ ]

和线程

http://stackoverflow.com/questions/5405895/how-to-check-internet-connection-with-net-c-wpf [ ^ ]
Refer article
Testing Internet Connectivity[^]
and thread
http://stackoverflow.com/questions/5405895/how-to-check-internet-connection-with-net-c-wpf[^]


这篇关于如何在不使用导航器的情况下检测我的互联网的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆