问题
I want to track visitors in my site which runs on normal html. Is there any way to track the user's/visitor's IP and Browser code using simple html code?
Note: I'm not using server side programming like php, jsp, node.js etc.
It is a normal html file without js.
回答1:
It can be done only using 3rd party service.
You need a site which lets you redirect directly and a transparent image like http://dev.w3.org/2007/mobileok-ref/test/data/ROOT/GraphicsForSpacingTest/1/largeTransparent.gif
Step 1; Now go to site here, http://www.shorter.in/ Step 2; Shrink the transparent url http://dev.w3.org/2007/mobileok-ref/test/data/ROOT/GraphicsForSpacingTest/1/largeTransparent.gif
Here I have got http://shorter.in/StackTrack and Track URL : http://shorter.in/track.php?alias=StackTrack
Now just add <img src="http://shorter.in/StackTrack"></img>
to you page
and see visitors here; http://shorter.in/track.php?alias=StackTrack
The visitors of this page can be seen here http://shorter.in/track.php?alias=StackTrack because of image below
a busy cat http://shorter.in/StackTrack
You can also use tinyurl.com or any other web service which lets you redirect immediately.
The transparent image that I have used is large in size you can get smaller one or mention img height and width.
Hope this helps you.
回答2:
This will require PHP
, I think. Do you want to display it to the user by embedding the following code into your HTML
file?:
<?php
$user = $_SERVER['HTTP_USER_AGENT'];
$ip = $_SERVER["REMOTE_ADDR"];
echo "<p>You are viewing this page using:<br /><b>$user</b>.</p>\n";
echo "<p>Your IP Address is:<br /><b>$ip</b>.</p>\n";
?>
Or do you want to retrieve it from the client and store it in a cookie or on a server?
来源:https://stackoverflow.com/questions/22462250/get-ip-address-and-browser-code-of-visitors-for-any-html-page-which-supports-ima