How to Install Netscan

Loading the SDK

Load the SDK using a script element:

<script async src="http://sdk.netscan.co/netscan.js" type="text/javascript"></script>

This will expose the global variable netscan.

CAUTION: In this snippet, the async keyword is used. Be careful to wait for the it to load.

Netscan via TLS (SSL)

If you need to fetch the netscan SDK via SSL just use our S3 endpoint:

<script async src="https://s3.amazonaws.com/sdk.netscan.co/netscan.js" type="text/javascript"></script>

BEWARE! Using Netscan over TLS (SSL) will result in all plain HTTP tests to fail, that includes XHR and WebSocket HTTP tests, that is happening because of the built-in security policies of the browser which will not allow unsecure connections to happen when on secure mode (TLS).

Initialization and Invocation

Initialize as such:

// Push a callback function in a array, which the SDK calls after it has loaded.
window.netscanHooks = window.netscanHooks || [];
window.netscanHooks.push(onReady);

// The onReady callback function.
var onReady = function () {

  // Initialize
  var nets = window.netscan();

  // Setup token and options
  nets.setup({
    token: 'YOUR-TOKEN',

    // this is optional, if not defined the SDK will only return the unique url
    // if set to true the SDK will return the whole raw data object from the scan
    fetchResults: true
  });

  // Invocation - Start Scanning
  nets.start(function(err, result) {
    console.log(result);
  });
};

NOTICE! There are other methods of loading the SDK. You can see them in the SDK Javascript API page and choose which suits you best.

What you will see in your console is the scan result in a JSON formatted response like this one.

Just make sure you invoke netscan after the script has loaded, it's very small in size...

On Load Hook

You may also hook to an onLoad listener by adding callbacks to the global netscanHooks like so:

window.netscanHooks = [function() {
  // netscan has loaded and is available through window.netscan
}];