Monday, 26 February 2018

Collect client information via javascript


function ClientEnvironmentData() {

    var data = [];
    data.push({ Key: "navigator.appName", Value: navigator.appName });
    data.push({ Key: "navigator.userAgent", Value: navigator.userAgent });
    data.push({ Key: "navigator.appVersion", Value: navigator.appVersion });
    data.push({ Key: "navigator.appCodeName", Value: navigator.appCodeName });
    data.push({ Key: "navigator.platform", Value: navigator.platform });
    data.push({ Key: "navigator.oscpu", Value: navigator.oscpu });
    data.push({ Key: "navigator.cookieEnabled", Value: navigator.cookieEnabled });
    data.push({ Key: "navigator.doNotTrack", Value: navigator.doNotTrack });
    data.push({ Key: "navigator.language", Value: navigator.language });
    data.push({ Key: "navigator.onLine", Value: navigator.onLine });
    data.push({ Key: "navigator.product", Value: navigator.product });
    data.push({ Key: "navigator.productSub", Value: navigator.productSub });
    data.push({ Key: "navigator.vendor", Value: navigator.vendor });
    data.push({ Key: "navigator.vendorSub", Value: navigator.vendorSub });

    data.push({ Key: "window.outerWidth", Value: window.outerWidth });
    data.push({ Key: "window.outerHeight", Value: window.outerHeight });
    data.push({ Key: "window.innerWidth", Value: window.innerWidth });
    data.push({ Key: "window.innerHeight", Value: window.innerHeight });

    this.getData = function() {
        return data;
    }

    this.getDataAsXml = function() {
        var xml = "";
        for (var i = 0; i < data.length; i++) {
            xml += "<" + data[i].Key + ">" + data[i].Value + "</" + data[i].Key + ">";
        }
        return xml;
    }
}

No comments:

Post a Comment