Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Display Content Based on IP Address

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #30319
    GreyFox135
    Participant

    Hi everyone! I’m currently interested in displaying a quick line or two of copy if a visiter’s IP address falls between a certain range. Do any of you have any resources or ideas of how I can go about it?

    I’d like to use JS for this. I’d imagine I can use JS to detect the IP then use an IF statement to display said content. I’m pretty new to JS and is the reason why I would love some help from ya’ll :)

    Any help is MUCH appreciated. Thnx!

    #79270
    coffeendonut
    Member

    yeah… all right ok … it can be possible but there is more than just js for this to work if u want to display content depending on country…etc… but if you know the IP address of the person then is much easier here is a php Snippet to get the job done…

    
    /*
    this Snippet allows you to display content "ONLY" to a visitor from
    a specific IP addresses in a page.
    Change the $allowed "value" to the IP address you want.
    */
    $allowed = '00.000.000.000';
    $userip = $_SERVER;
    if($userip == $allowed){
    echo "This content is only viewed by the IP address you chose...";
    }
    ?>
    #79242
    GreyFox135
    Participant

    Thanks man, not exactly what I was looking for, but it’s good to know the php side of things.

    I’m really trying to do this with JS. I’m also trying to do a range of IP addresses.

    Thanks for your input!

    #79090
    loki
    Member

    #107128
    ganesh
    Member

    You can find the IP address and the location details using ip-details.com.
    It gives your current ip address and location details with the location
    map with latitude, longitude coordinates.

    #107132
    AntonNiklasson
    Participant
    #135262
    varunramesh
    Member

    use the javascript service provided by geolify.com

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.