如何在html javascript中跟踪访问者ip

时间:2015-12-30 04:18:14

标签: javascript php jquery html tracking

如何让访问ip的功能? 我尝试修复使用下面的相关帖子 Tracking visitor IP/Clicks in PHP How to get client's IP address using javascript only? 但还不能修好..



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sample Tracking Visitor</title>
<script type="text/javascript">
	function tracking_vistors(cid,url,curl,camp,type) {
	   var user_agent = getuseragent();
	   var ip = myIP(); // how to make this function track visitor ip 
	   var publisher = "2000000001";
	   var data = "cid="+cid+"&curl="+curl+"&camp="+camp+"&type="+type+"&url="+url+"&ip="+ip+"&user_agent="+user_agent+"&publisher="+publisher;
	   $.ajax({
				  type: 'POST',
				  url: 'widget/clicktracker.php',
				  data: data
			 });
	}

</script>
</head>

<body>
</body>
</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

您无法从javascript中找到IP。您必须将呼叫发送到互联网或任何其他可以返回您的IP的服务..

我正在添加一个将返回您的IP的服务网址。

ash, dash, ksh, sh

此行将请求发送到l2.io域并返回我在上面的代码中使用的myip变量中的ip。

相关问题