Search

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

Get client IP, Location, Address using just JavaScript?





I would use a web service that can return JSON (along with jQuery to make things simpler). Below are all the free active IP lookup services I could find and the information they return. If you know of any more, then please add a comment and I'll update this answer.


db-ip.com

http://api.db-ip.com/addrinfo?api_key=<your_api_key>&addr=<your_ip_address>

Returns:

{
  "address": "116.12.250.1",
  "country": "SG",
  "stateprov": "Central Singapore",
  "city": "Singapore"
}

Limitations:

  • 2,500 requests per hour
  • Doesn't support JSONP callbacks
  • Requires IP address parameter

geobytes.com

$.getJSON('//gd.geobytes.com/GetCityDetails?callback=?', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

Returns:

{
  "geobytesforwarderfor": "",
  "geobytesremoteip": "116.12.250.1",
  "geobytesipaddress": "116.12.250.1",
  "geobytescertainty": "99",
  "geobytesinternet": "SA",
  "geobytescountry": "Saudi Arabia",
  "geobytesregionlocationcode": "SASH",
  "geobytesregion": "Ash Sharqiyah",
  "geobytescode": "SH",
  "geobyteslocationcode": "SASHJUBA",
  "geobytescity": "Jubail",
  "geobytescityid": "13793",
  "geobytesfqcn": "Jubail, SH, Saudi Arabia",
  "geobyteslatitude": "27.004999",
  "geobyteslongitude": "49.660999",
  "geobytescapital": "Riyadh ",
  "geobytestimezone": "+03:00",
  "geobytesnationalitysingular": "Saudi Arabian ",
  "geobytespopulation": "22757092",
  "geobytesnationalityplural": "Saudis",
  "geobytesmapreference": "Middle East ",
  "geobytescurrency": "Saudi Riyal",
  "geobytescurrencycode": "SAR",
  "geobytestitle": "Saudi Arabia"
}

Limitations:

  • 16,384 requests per hour
  • Returns the wrong location (I'm in Singapore, not Saudi Arabia)

geoplugin.com

$.getJSON('//www.geoplugin.net/json.gp?jsoncallback=?', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

Returns:

{
  "geoplugin_request": "116.12.250.1",
  "geoplugin_status": 200,
  "geoplugin_credit": "Some of the returned data includes GeoLite data created by MaxMind, available from <a href=\\'http://www.maxmind.com\\'>http://www.maxmind.com</a>.",
  "geoplugin_city": "Singapore",
  "geoplugin_region": "Singapore (general)",
  "geoplugin_areaCode": "0",
  "geoplugin_dmaCode": "0",
  "geoplugin_countryCode": "SG",
  "geoplugin_countryName": "Singapore",
  "geoplugin_continentCode": "AS",
  "geoplugin_latitude": "1.2931",
  "geoplugin_longitude": "103.855797",
  "geoplugin_regionCode": "00",
  "geoplugin_regionName": "Singapore (general)",
  "geoplugin_currencyCode": "SGD",
  "geoplugin_currencySymbol": "&#36;",
  "geoplugin_currencySymbol_UTF8": "$",
  "geoplugin_currencyConverter": 1.4239
}

Limitations:

  • 120 requests per minute

hackertarget.com

http://api.hackertarget.com/geoip/?q=<your_ip_address>

Returns:

IP Address: 116.12.250.1
Country: SG
State: N/A
City: Singapore
Latitude: 1.293100
Longitude: 103.855797

Limitations:

  • 50 requests per day
  • Only returns plain text
  • Requires IP address parameter

ip-api.com

$.getJSON('//ip-api.com/json?callback=?', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

Returns:

{
  "as": "AS3758 SingNet",
  "city": "Singapore",
  "country": "Singapore",
  "countryCode": "SG",
  "isp": "SingNet Pte Ltd",
  "lat": 1.2931,
  "lon": 103.8558,
  "org": "Singapore Telecommunications",
  "query": "116.12.250.1",
  "region": "",
  "regionName": "",
  "status": "success",
  "timezone": "Asia/Singapore",
  "zip": ""
}

Limitations:

  • 150 requests per minute

ipify.org

$.getJSON('//api.ipify.org?format=jsonp&callback=?', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

Returns:

{
  "ip": "116.12.250.1"
}

Limitations:

  • None (unlimited bandwidth)

ipinfo.io

$.getJSON('//ipinfo.io/', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

Returns:

{
  "ip": "116.12.250.1",
  "hostname": "No Hostname",
  "city": "Singapore",
  "region": "",
  "country": "SG",
  "loc": "1.2931,103.8558",
  "org": "AS3758 SingNet"
}

Limitations:

  • 1,000 requests per day

ipinfodb.com

$.getJSON('//api.ipinfodb.com/v3/ip-city/?key=<your_api_key>&format=json&callback=?', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

Returns:

{
  "statusCode": "OK",
  "statusMessage": "",
  "ipAddress": "116.12.250.1",
  "countryCode": "SG",
  "countryName": "Singapore",
  "regionName": "Singapore",
  "cityName": "Singapore",
  "zipCode": "048941",
  "latitude": "1.28967",
  "longitude": "103.85",
  "timeZone": "+08:00"
}

Limitations:

  • Two requests per second
  • Requires registration to get your API key

ip-json

http://ip-json.rhcloud.com/json

Returns:

{
  "site": "http://ip-json.rhcloud.com",
  "city": "Singapore",
  "region_name": null,
  "region": "00",
  "area_code": 0,
  "time_zone": "Asia/Singapore",
  "longitude": 103.85579681396484,
  "metro_code": 0,
  "country_code3": "SGP",
  "latitude": 1.2930999994277954,
  "postal_code": null,
  "dma_code": 0,
  "country_code": "SG",
  "country_name": "Singapore",
  "q": "116.12.250.1"
}

Limitations:

  • Quota not stated, but may be limited by OpenShift PaaS
  • Doesn't support JSONP callbacks

jsonip.com

$.getJSON('//jsonip.com/?callback=?', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

Returns:

{
  "ip": "116.12.250.1",
  "about": "/about",
  "Pro!": "http://getjsonip.com"
}

Limitations:

  • None (unlimited bandwidth)

jsontest.com

$.getJSON('//ip.jsontest.com/?callback=?', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

Returns:

{
  "ip": "116.12.250.1"
}

Limitations:

  • Goes down a lot (over quota), so I wouldn't use it for production

snoopi.io

http://api.snoopi.io/v1/

Returns:

{
  "remote_address": "116.12.250.1",
  "requested_address": "116.12.250.1",
  "requested_time": "11:25:35 pm",
  "requested_date": "January 31, 2016",
  "CountryCode": "SG",
  "Region": null,
  "Region_Full": "Singapore",
  "City": "Ubi",
  "PostalZip": "96940",
  "TimeZone_Name": "Asia\/Singapore",
  "Latitude": "1.31865",
  "Longitude": "103.894"
}

Limitations:

  • 2,500 requests per day
  • Doesn't support JSONP callbacks


'Programming > JAVA,JSP' 카테고리의 다른 글

Java Applet 설정  (0) 2017.02.28
Java SocketServer control Image, DBConnect, String  (1) 2016.10.28
Web Browser 점유율 통계  (0) 2016.04.18
Activex Event use in JavaScript  (0) 2016.04.14
JDBC Realm  (1) 2016.03.09

Activex Event use in JavaScript

Programming/JAVA,JSP 2016. 4. 14. 11:26 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

If you want to use Activex Event in JavaScript 



You commonly use JavaScript Event listener


1.  

<script type="text/javascript" for="ActiveXControl" event="LogOn()"></script>


2.   

var ctrl = document.getElementById("ActiveXControl");

ctrl.attachEvent('LogOn', ActiveXControl_LogOn);


function ActiveXControl_LogOn() {

        

}


3.   

var ctrl = document.getElementById("ActiveXControl");

ctrl.addEventListener('LogOn', ActiveXControl_LogOn, false);



function ActiveXControl_LogOn() {

        

}



This way can't use correctly alert method. you can see alert only in debug mode.


I think this situation is have a thread problem.



I suggest other way to use eventhandling


By use timer, This problem can be solved.



// make eventArray 

var eventArray = [];


// if event occured, when you add information to eventArray

eventArray.push(information);


// make Timer

setInterval(function () {

if (eventArray.length > 0) {

var information= eventArray.pop();

alert("information: " + information);

}

}, 100);



This method can be use alert method







'Programming > JAVA,JSP' 카테고리의 다른 글

Get client IP, Location, Address using just JavaScript?  (0) 2016.04.26
Web Browser 점유율 통계  (0) 2016.04.18
JDBC Realm  (1) 2016.03.09
ImageFrameTest  (0) 2016.02.05
Java 채팅 프로그램  (0) 2016.02.04