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
  • #30319

    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!


    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 = '';
    $userip = $_SERVER;
    if($userip == $allowed){
    echo "This content is only viewed by the IP address you chose...";

    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!



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


    use the javascript service provided by

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