sabato 22 febbraio 2014

Gather client information with javascript

Hi guys I'm here with a post about all the info about the client that can be gathered with javascript.

IP ADDRESS:

var ip;

function getip(json){
ip = json.ip;
} 


Using JSON is probably the easiest way to get the client's IP address.



BROSWER NAME AND VERSION


var navigatorCodeName = navigator.appCodeName;
var navigatorName = navigator.appName;
var navigatorVersion =  navigator.appVersion;

Simple and clear.

CLIENT PLATFORM

var platform = navigator.platform;

ARE COOKIES ENABLED?

var cookiesEnabled = navigator.cookieEnabled;

PLUGINS

var txt;

txt+="Number of detected plugins: " + navigator.plugins.length + "<br>";

for(i = 0; i<navigator.plugins.length; i++){
txt+="Plugin N°" + i+1 + " --> name = " + navigator.plugins[i].name + " --> location = " + navigator.plugins[i].filename + "<br>";
}


alert(txt);

First of all we gather the number of plugins, then we make a list of them.

HISTORY LENGTH IN THE CURRENT SESSION

var historyLength = window.history.length;

CLIENT'S LOCATION

if(google.loader.ClientLocation){
visitor_lat = google.loader.ClientLocation.latitude;
visitor_lon = google.loader.ClientLocation.longitude;
visitor_city = google.loader.ClientLocation.address.city;
visitor_region = google.loader.ClientLocation.address.region;
visitor_country = google.loader.ClientLocation.address.country;
visitor_countrycode = google.loader.ClientLocation.address.country_code;
}
else{

alert("Script were unable to get your location");
}


I hope you'll find these stuffs useful, here is a demonstration of them.

If you have any question just comment.

Bye, Dami 
    

Nessun commento:

Posta un commento