admin管理员组文章数量:1425667
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 badges3 Answers
Reset to default 4You 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.
本文标签: javascriptIP Address Lookup in a Firefox ExtensionStack Overflow
版权声明:本文标题:javascript - IP Address Lookup in a Firefox Extension - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745446732a2658696.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论