IP

Discussions about Forms Designer for SharePoint 2010.
Locked
User avatar
Sebastian Haugland
Posts: 43
Joined: Fri Sep 19, 2014
Contact:

26 Oct 2015

Hi

I would like to see the IP of the client (to determine the location of the user), any ideas?

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

27 Oct 2015

Here are a couple of options:

1. Use a REST service, e.g.

Code: Select all

$.ajax({
       url: "http://freegeoip.net/json/"
    }).then(function(data) {
       console.log(data.ip); //data contains other things, like country, latitude, longitute, etc
    });
2. Append a 3rd party script to your page: Add this code on form load:

Code: Select all

$('head').append('<script type="text/javascript" src="http://l2.io/ip.js?var=myip"></script>')
This will append a script to your page. Then you will be able to access the IP via myip variable, e.g.:

Code: Select all

alert(myip);
This (probably) wouldn't work if your site uses the https protocol. Also, from stackoverflow: "...this can be easily spoofed (through either use of proxies or spoofed request headers...".

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 7 guests