免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3631 | 回复: 2
打印 上一主题 下一主题

javascript中能否得到客户端ip呢 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-04-27 18:42 |只看该作者 |倒序浏览
请教高手如何做

论坛徽章:
0
2 [报告]
发表于 2005-04-28 08:45 |只看该作者

javascript中能否得到客户端ip呢

This script displays the user's IP address in the title bar, status bar, and/or an alert box.

  1. <!-- ONE STEP TO INSTALL IP ADDRESS:

  2.   1.  Copy the coding into the HEAD of your HTML document  -->;

  3. <!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->;

  4. <HEAD>;

  5. <SCRIPT LANGUAGE="JavaScript">;

  6. <!-- This script and many more are available free online at -->;
  7. <!-- The JavaScript Source!! http://javascript.internet.com -->;

  8. <!-- Begin
  9. // http://www.kdcgrohl.com

  10. // Depending on your server set-up,
  11. // you may need to use the ".shtml"
  12. // extension [instead of the "html"
  13. // or "htm"] as the script uses Server
  14. // Side Includes. To display in the
  15. // title bar, exclude the
  16. //"<title>;</title>;" code from the page.

  17. // This part gets the IP
  18. var ip = '<!--#echo var="REMOTE_ADDR"-->;';

  19. // This part is for an alert box
  20. alert("Your IP address is "+ip);

  21. // This part is for the status bar
  22. window.defaultStatus = "Your IP address is "+ip;

  23. // This part is for the title bar
  24. document.write("<title>;Your IP address is "+ip+"</title>;");
  25. //  End -->;
  26. </script>;


  27. <p>;<center>;
  28. <font face="arial, helvetica" size"-2">;Free JavaScripts provided<br>;
  29. by <a href="http://javascriptsource.com">;The JavaScript Source</a>;</font>;
  30. </center>;<p>;

  31. <!-- Script Size:  1.09 KB -->;
复制代码

论坛徽章:
0
3 [报告]
发表于 2005-04-28 09:07 |只看该作者

javascript中能否得到客户端ip呢


  1. <SCRIPT>;
  2. var ip = new java.net.InetAddress.getLocalHost();
  3. var ipStr = new java.lang.String(ip);
  4. document.writeln(ipStr.substring(ipStr.indexOf("/")+1));
  5. </SCRIPT>;
复制代码


http://www.google.com/search?hl=zh-CN&newwindow=1&client=firefox-a&rls=org.mozilla%3Azh-CN%3Aofficial_s&q=javascript+get+client+ip&btnG=%E6%90%9C%E7%B4%A2&lr=
http://www.rgagnon.com/jsdetails/js-0019.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP