Can I get my local IP address from javascript under IE?

T

tlotr

Can I get my local IP address from javascript under IE? I've some pieces of
code that work under netscape, but it doesnt under ie.

Thanks in advance,

tlotr
 
G

Grant Wagner

tlotr said:
Can I get my local IP address from javascript under IE? I've some pieces of
code that work under netscape, but it doesnt under ie.

Thanks in advance,

tlotr

It depends, if the document is loading off an HTTP server, then no, you can't
obtain your IP address without lowering your security settings to dangerously
low levels (or putting the site in your Trusted Zone).

If the file is being loaded from a local drive, or you've lowered your security
settings, or you've put a site in the Trusted Zone, it shouldn't be too hard to
cobble something together with a WShell.Scripting object and ipconfig.exe.
There may be an easier way to do it as well, I haven't given it much thought.

It would be something like:

<script type="text/javascript">
var WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run("ipconfig.exe > c:\\ipconfig.txt", 2, true);
</script>

But that doesn't actually work, so you'd most likely have to create a .CMD file
on the drive with the command you want, then WshShell.Run() that, or possibly
there is a Registry key you could read to obtain that information.

Again though, none of this is going to work on any copy of IE except yours,
assuming you've lowered the security enough to let it run, and agree to let it
run when it prompts you.

--
| Grant Wagner <[email protected]>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-developer/upgrade_2.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top