Online Shopping : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to
Did You Find This Entry Useful?

31 of 87 people (36%) answered Yes
Recently 5 of 10 people (50%) answered Yes


how can i have the IP,REMOTE_ADDR, HTTP_USER_AGENT, SERVER_PROTOCOL etc... of the internetsurfer that visit my homepage and show it in a webpage?

Feb 24th, 2009 23:18
haytham ali, ha mo, Colin Fraser, paolo tonelli,

When I put the original answer to this question it was not tested and 
there were errors in it, here is a revamped answer and this one works. 
At least, it works in my browser, on my computer.  
In your first document, place a link to this page eg. 
<a href="visitor.html">Who are you? </a>
<title>Who you are </title>
<SCRIPT LANGUAGE="javascript">
// This script prompts for information and places it upon the page 
var username = prompt ("Please enter your name in the prompt","Place it 
here, thank you");
document.write("Hello <font size=+1>" + username + "</font>. Welcome to 
my page!<p>");
<SCRIPT LANGUAGE="javascript">
document.write("The browser you are using is <b>" +navigator.appName+ 
"</b>, version " +navigator.appVersion+ ".<br>Its code name is 
"+navigator.appCodeName+ ", and sends the header " +navigator.userAgent+ 
"." );
The object used here is "navigator", you may want to go and have a look 
at the properties of JavaScript Objects in Netscape's developer site at
Netscape provides a couple of PDF documents detailing objects and their 
properties as well as how to refer to them. Well worth the look. </p> 
<SCRIPT LANGUAGE="javascript">
document.write("The background colour of this page is <b>" 
+document.bgColor+ "</b>.")
document.write("<br>The text colour of this page is <b>" 
+document.fgColor+ "</b>.")
document.write("<br>The URL of this page is <b>" +document.location+ 
document.write("<br>The last page you visited was <b>" 
+document.referrer+ "</b>.")
document.write("You visited " +history.length+ " pages before this one 
in this session.")
document.write("<br>The TITLE of this page is <b>" +document.title+ 
document.write("<br>The document was last modified: <b>" 
+document.lastModified+ "</b>.")
document.write("The name of this location is <b>" + location.hostname + 
Privacy issues cloud access to the name and url of the last page 
visited, I suspect a lot of people would be unhappy at your accessing 
their history object and displaying it to screen. The location is 
determined by the server, so if you are using this from a hard drive it 
is not going to work The URL of the page is not the location of the 
visitor's server. Make sure the only breaks in the lines are those where 
a line automatically wraps or where a new command begins a new line. 
There is some information that you may not be able to display in you 
visitor's browser. 
I hope this answers your question better than my previous attempt did.