On Tue, May 18, 2010 at 12:37 PM, jyothi panidarapu
<[email protected]> wrote:
> Is there anyway through javascript to find the ip address locally, by  not
> querying any other external websites?

Until Firefox 3.5.something, this used to work, but it does no longer
do, I don't know why. Maybe you can fix it.

var sk = unsafeWindow.java.net.Socket(document.location.host,
                                   document.location.port || 80);
// Remot host name, ip an port
var hst = sk.getInetAddress().getHostName();
var rip = sk.getInetAddress().getHostAddress();
var rpt = sk.getPort();
// Local host ip and port (not loopback iface but local network adress)
var lip = sk.getLocalAddress().getHostAddress();
var lpt = sk.getLocalPort();

alert([
  'Remote Host: ' + hst,
  'Remote IP: '   + rip,
  'Remote Port: ' + rpt,
  '---------------------------------------------------------' ,
  'Local IP: '    + lip,
  'Local Port: '  + lpt
].join ('\n'));

-- 
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/greasemonkey-users?hl=en.

Reply via email to