locked
OBTAINING MY IP ADDRESS

    Question

  • I want to retrieve my computer ip address to my javascript and html5 project. how do I obtain my computer ipaddress and display it in my project.

    1002614D

    Thursday, June 28, 2012 2:18 AM

Answers

  • You can use the Windows API to retrieve your network connection information.  For your particular case, one way to retrieve your current IP address is:

    var ipAddress;
    var networkInfo = Windows.Networking.Connectivity.NetworkInformation;
    var hosts = networkInfo.getHostNames();
    hosts.forEach(function (host) {
          if (host.type === Windows.Networking.HostNameType.ipv4) {  
             ipAddress = host.rawName;
          }
    });
    For more information on the networking API namespace, see http://msdn.microsoft.com/en-us/library/windows/apps/br207124.aspx

    This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, June 28, 2012 6:27 PM

All replies