|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
If there is nothing there (i.e. TCP/IP has been removed from the Network section of the computer), the following code breaks and the executable crashes.
Putting TCP/IP back in fixes the problem it seems. Is there an error check that could be put in to prevent this? Cheers. //create a new Inet object to access the network configuration of the computer, if there is any set up var inet = new Inet(); //ic: the network configuration of the computer var ic = inet.getIPConfig(); //netsettings: gets set if any extra network settings are detected var netsettings = false; //check each network interface, and if one or more exist that are not just the local loopback, ask the user if they are sure about continuing. for (i = 0; i < ic.ifNum; i++) { var ip = ic.ifIP(i); if ((ip.toString() != '127.0.0.1') && (ip.toString() != '0.0.0.0') && (ip.toString().indexOf('169.254.') != 0)){ netsettings = true; } } |
|
|||
|
you can check the object for validity before attempting to use it.
Code:
//create a new Inet object to access the network configuration of the computer, if there is any set up
var inet = new Inet();
if (!inet=="undefined"){
//ic: the network configuration of the computer
var ic = inet.getIPConfig();
//netsettings: gets set if any extra network settings are detected
var netsettings = false;
//check each network interface, and if one or more exist that are not just the local loopback, ask the user if they are sure about continuing.
for (i = 0; i < ic.ifNum; i++) {
var ip = ic.ifIP(i);
if ((ip.toString() != '127.0.0.1') && (ip.toString() != '0.0.0.0') && (ip.toString().indexOf('169.254.') != 0)){
netsettings = true;
}
}
}
else{
//do something here if the inet object couldn't be created.
}
-Umpa |
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|