javascript做为前端语言,ie里没有这个功能。ns可以用java实现

解决方案 »

  1.   

    NN4 (and NN3 I think but I haven't checked the code with it) allows 
    that by calling into Java:
      var localhost = java.net.InetAddress.getLocalHost();
      var hostname = localhost.getHostName();
      var hostIP = localhost.getHostAddress();  alert('You are visiting from host ' + hostname  
            + ' with ip address ' + hostIP);The only way with IE to use Java is an applet but the above code 
    (transcribed into Java) run in an applet is reported to return
      localhost
    for the hostname respectively
      127.0.0.1
    for the ip address.So all you can do for IE (and Opera and NN6) is to use server side 
    assists meaning a cgi script or php script dynmically returning the 
    REMOTE_ADDR cgi variable. I have set up such an assists at
      http://www.csdn.net/jshelper/ipAddress.php
    which returns a statement of the form
      var ipAddress = '123.123.123.123;
    so that a script can then access the variable
      ipAddress
    to read the value e.g.<HTML>
    <HEAD>
    <SCRIPT SRC="http://www.csdn.net/jshelper/ipAddress.php">
    </SCRIPT>
    </HEAD>
    <BODY>
    <SCRIPT>
    document.write(ipAddress)
    </SCRIPT>
    </BODY>
    </HTML>
      

  2.   

    写一个ipAddress.php文件,输出
    ipAddresss=<?=$REMOTE_ADDR?>然后
    <HTML>
    <HEAD>
    <SCRIPT SRC="ipAddress.php">
    </SCRIPT>
    </HEAD>
    <BODY>
    <SCRIPT>
    document.write(ipAddress)
    </SCRIPT>
    </BODY>
    </HTML>