如何通过JS得到访问者的IP
发布网友
发布时间:2022-04-21 17:56
我来回答
共1个回答
热心网友
时间:2022-04-22 22:36
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<script type="text/javascript" src="js/jquery/jquery-1.8.1.min.js"></script>
<body>
</body>
<!-- 通过hashemian.com查询本机IP -->
<script type="text/javascript" src="http://scripts.hashemian.com/js/visitorIPHOST.js.php">
</script>
<script type="text/javascript">
var data = $("td:parent")[0].lastChild.data;
var ip = data.substring(6,data.length);
alert(ip);
</script>
</html>