Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6104465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:50:43+00:00 2026-05-23T13:50:43+00:00

I am using javascript to determine the visitors ip address. For what ever reason,

  • 0

I am using javascript to determine the visitors ip address. For what ever reason, it works in Chrome and not in Firefox, IE, or other browsers.

Here is my code:

function getIPAddress() {
    var xmlHttp;

    if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    } else {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlHttp.open("GET", "http://api.hostip.info/get_html.php", false);
    xmlHttp.send();

    var hostipInfo = xmlHttp.responseText.split("\n");

    for (var i = 0; i < hostipInfo.length - 1; i++) {
        var ipAddress = hostipInfo[i].split(":");
        if (ipAddress[0] == "IP") return ipAddress[1];
    }

    return "unknown";
}

At the company I’m working for, I am behind a proxy. Could this be a proxy issue, or is there something wrong with this code? Thanks.

Just deployed my code to our test environment, and in IE, I receive a pop up saying ‘This page is accessing information that is not under its control. This poses a security risk. Do you want to continue?’ If I say, yes, it works. If I say, no, it doesn’t.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:50:43+00:00Added an answer on May 23, 2026 at 1:50 pm

    If you’re going to use AJAX (which is what this code is), I STRONGLY suggest you use a 3rd party wrapper like jQuery. That will increase cross-browser compatibility greatly and allows you to shrink your code down to something like this.

    $.post('http://api.hostip.info/get_html.php', function(data){
        alert(data);
    });
    

    Additional Point

    As Pointy mentioned, if your page is running on a different domain than hostip.info, you will need to setup a local PHP to fetch the data like this..

    localGetData.php

    die(file_get_contents('http://api.hostip.info/get_html.php'));
    

    New Ajax

    $.post('localGetData.php', function(data){
        alert(data);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using JavaScript, how can I determine the size of an image which is not
Is there a way (preferrably using JavaScript) to determine whether a URL is to
So, I have to determine page type in a proprietary CRM, using JavaScript. The
Is there a method using either JavaScript or jQuery to determine what day of
Is there any way to determine in Javascript if an object was created using
Is there a way to determine whether or not a CSS class exists using
Can someone tell me how I can determine (using JavaScript etc.) what browser is
I'm changing the img src on click using javascript. I'm trying to determine whether
Using Javascript, is there a way that I can determine the size of a
I'm using javascript/jQuery.. on the keydown of an input[type='text'] I receive a key code.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.