导航:首页 > 无线网络 > js网络信息ua判断wifi

js网络信息ua判断wifi

发布时间:2022-09-11 21:11:39

㈠ 使用JS在浏览器中判断当前网络连接状态的几种方法

通过navigator.onLine判断当前网络状态:
if(navigator.onLine){

...}else{ ...}

非常简单,但是并不准确-根据MDN的描述:

navigator.onLine只会在机器未连接到局域网或路由器时返回false,其他情况下均返回true。

也就是说,机器连接上路由器后,即使这个路由器没联通网络,navigator.onLine仍然返回true。

㈡ 求助,js如何检测 移动端 网络信号

<script type="text/javascript">
function browserRedirect() {
var sUserAgent = navigator.userAgent.toLowerCase();
var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
var bIsMidp = sUserAgent.match(/midp/i) == "midp";
var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
var bIsAndroid = sUserAgent.match(/android/i) == "android";
var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
if (!(bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) ){
window.location.href=B页面;
}
}
browserRedirect(); </script>

㈢ jquery或者js如何判断当前网络是否畅通,我的页面是给手机用的

代码逻辑如下:

jQuery.ajax({
url:"",
dataType:"",
type:"",
success:function(data){
//...调用成功代码
},
error:function(XMLHttpRequest,textStatus,errorThrown){
alert(XMLHttpRequest.status);//查看请求状态
//调用失败代码
}
});

通过ajax的error参数判断当前网络状况。

㈣ js判断手机是wifi还是流量

以下代码仅供参考:

<scripttype="text/javascript">
varconnection=navigator.connection||navigator.mozConnection||navigator.webkitConnection||{tyep:'unknown'};
vartype_text=['unknown','ethernet','wifi','2g','3g','4g','none'];

alert(connection.type);
varre_el=document.getElementById("re");
varbtn_el=document.getElementById("btn");
functionget_status(){
if(typeof(connection.type)=="number"){
connection.type_text=type_text[connection.type];
}else{
connection.type_text=connection.type;
}
if(typeof(connection.bandwidth)=="number"){
if(connection.bandwidth>10){
connection.type='wifi';
}elseif(connection.bandwidth>2){
connection.type='3g';
}elseif(connection.bandwidth>0){
connection.type='2g';
}elseif(connection.bandwidth==0){
connection.type='none';
}else{
connection.type='unknown';
}
}
varhtml='Type:'+connection.type_text;
html+='<br>Bandwidth:'+connection.bandwidth;
html+='<br>isOnline:'+navigator.onLine;
re_el.innerHTML=html;
}

btn_el.onclick=function(){
re_el.innerHTML='Waiting...';
get_status();
}

</script>

怎么用js脚本判断自动检测网络连接是否正常

用AJAX

㈥ 求一段JS代码,可以根据UA判断不通的操作系统显示不同的代码!

varcheckSystem=function(){
varuaMap={
'android':/Android/i,
'ios':/(?:iPhone|iPad)/i
};
varua=window.navigator.userAgent;
for(variinuaMap){
if(uaMap[i].test(ua)){
returni;
}
}
returnnull;
};

然后直接用

checkSystem()=='ios'


checkSystem()=='android'

判断。

或者直接这样

document.body.className=checkSystem();

这样body上就有系统的class了。

控制CSS就能控制如何显示了。

㈦ 如何用 js 或 php 判断手机网络环境

JS代码 http://www..com/ 换成手机页面地址
<script type="text/javascript">

if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i))) {

location.replace("http://www..com/");

}

</script>
PHP代码

if(!function_exists('isMobile'))
{
function IsMobile()
{

//如果有HTTP_X_WAP_PROFILE则一定是移动设备
if(isset($_SERVER['HTTP_X_WAP_PROFILE'])) return TRUE;

//如果via信息含有wap则一定是移动设备,部分服务商会屏蔽该信息
if(isset($_SERVER['HTTP_VIA']))
{
//找不到为flase,否则为true
return stristr($_SERVER['HTTP_VIA'], "wap") ? true : false;
}

//判断手机发送的客户端标志,兼容性有待提高
if(isset($_SERVER['HTTP_USER_AGENT']))
{

$clientkeywords = array('nokia','sony','ericsson','mot','samsung','htc','sgh','lg','sharp','sie-','philips','panasonic','alcatel','lenovo','iphone','ipod','blackberry','meizu','android','netfront','symbian','ucweb','windowsce','palm','operamini','operamobi','openwave','nexusone','cldc','midp','wap','mobile');

//从HTTP_USER_AGENT中查找手机浏览器的关键字
if(preg_match('/('.implode('|', $clientkeywords).')/i', strtolower($_SERVER['HTTP_USER_AGENT'])))
{
return TRUE;
}
}

//协议法,因为有可能不准确,放到最后判断
if(isset($_SERVER['HTTP_ACCEPT']))
{
//如果只支持wml并且不支持html那一定是移动设备
//如果支持wml和html但是wml在html之前则是移动设备
if((strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') !== false) &&
(strpos($_SERVER['HTTP_ACCEPT'], 'text/html') === false ||
(strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') < strpos($_SERVER['HTTP_ACCEPT'], 'text/html'))))
{
return TRUE;
}
}

return FALSE;
}
}

//php 调用
if(IsMobile())
{
header('location:http://www..com/');
}

阅读全文

与js网络信息ua判断wifi相关的资料

热点内容
笔记本和台式机通过网线共享网络 浏览:635
共享网络怎么设置禁止 浏览:900
电脑能上网但网络显示不安全 浏览:280
红米手机为什么一锁屏网络就断了 浏览:845
网络营销和电话销售 浏览:605
iphone连接wifi显示无网络 浏览:733
苹果x蜂窝网络不好用 浏览:207
移动魔百盒有信号没有网络 浏览:959
光猫复原后无法连接网络 浏览:156
网络安全评估指标 浏览:152
网络语言画画摸鱼是什么意思 浏览:62
网络作家赚钱大概能有多少 浏览:405
苹果手机网络和流量 浏览:436
苹果王者荣耀不提醒我设置网络 浏览:949
mac网络连接设置 浏览:615
哈啰顺风车接单网络异常 浏览:10
中国移动通信网络安全 浏览:876
用无线网络打开网页慢 浏览:262
招聘网络哪个多 浏览:100
身边哪些地方使用了网络 浏览:675

友情链接