YPCrumble
YPCrumble

Reputation: 28722

How do I detect a user's IP address using javascript?

I want to disable a script (mixpanel tracking software) for users from two unique IP addresses that are my AWS servers - is there a javascript function to do this automatically from the front-end?

I'm looking for something like this:

if (!(ipaddress1 || ipaddress2)){
    //run the script
}

Upvotes: 0

Views: 901

Answers (1)

SomeKittens
SomeKittens

Reputation: 39522

There's no native way to do this, you'll need to use a service like jsonip (currently over quota) or you could make an AJAX request to your server (where you do have access to the requesting IP) and return it, bypassing the need for an external service.

Upvotes: 3

Related Questions