javascript - IP Address Lookup in a Firefox Extension - Stack Overflow

I'm writing a Firefox extension and I need to find the ip address of the currently loaded page.I

I'm writing a Firefox extension and I need to find the ip address of the currently loaded page. I can get the hostname of the page with window.location.host, but is there any way to find the ip for that hostname?

I tried looking for the answer at the Mozilla Developer Center but was unable to find anything.

EDIT: I would use something like PHP to do this, but cannot, because it's a firefox extension, running on the client side only. I have no web server to do back end PHP.

I'm writing a Firefox extension and I need to find the ip address of the currently loaded page. I can get the hostname of the page with window.location.host, but is there any way to find the ip for that hostname?

I tried looking for the answer at the Mozilla Developer Center but was unable to find anything.

EDIT: I would use something like PHP to do this, but cannot, because it's a firefox extension, running on the client side only. I have no web server to do back end PHP.

Share Improve this question edited Jul 4, 2009 at 18:44 mishac asked Jul 4, 2009 at 18:20 mishacmishac 3,3141 gold badge23 silver badges19 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4

You could look at how the ShowIP Firefox extension does it.

var cls = Cc['@mozilla/network/dns-service;1'];
var iface = Ci.nsIDNSService;
var dns = cls.getService(iface); //dns object

var nsrecord = dns.resolve(HOSTNAME_HERE, true); //resolve hostname
while (nsrecord && nsrecord.hasMore()){
   alert(nsrecord.getNextAddrAsString()); //here you are
}

If not a PHP Lookup, do a simple nslookup, or dig for hostname string.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745446732a4628080.html

相关推荐

  • javascript - IP Address Lookup in a Firefox Extension - Stack Overflow

    I'm writing a Firefox extension and I need to find the ip address of the currently loaded page.I

    7小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信