Before you begin, see Connection Functions.

Getting the connection type

<cfclientsettings enableDeviceAPI=true>

<cfclient>

<cfset conType = cfclient.connection.getType()>
<cfset document.getElementById('result').innerHTML=document.getElementById('result').innerHTML+"Type: #conType#"> 

</cfclient>
 
<div id="result"/>

Valid connection types  are Connection.UNKNOWN, Connection.ETHERNET, Connection.WIFI, Connection.CELL_2G, Connection.CELL_3G, Connection.CELL_4G, Connection.CELL, and Connection.NONE.

Finding if the connection is offline

<cfclientsettings enableDeviceAPI=true>

<cfclient>
 
<cfset cfclient.connection.onOffline('callback1')>
 
<cffunction name="callback1" >
<cfset document.getElementById('result').innerHTML=document.getElementById('result').innerHTML+"The mobile connection has been lost">
</cffunction> 

</cfclient>
 
<div id="result"/>

Finding if the connection is online

<cfclientsettings enableDeviceAPI=true>

<cfclient>
 
<cfset #cfclient.connection.onOnline('callback1')#>
 
<cffunction name="callback1" >
<cfset document.getElementById('result').innerHTML=document.getElementById('result').innerHTML+"The mobile connection is active now">
</cffunction> 

</cfclient>

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy