faqts : Computers : Programming : Languages : JavaScript : Event handling

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

12 of 19 people (63%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

Is it possible to get an email(with information about a visitor- IP etc.) sent every time a HTML page is loaded(Form? in onload?)?

Dec 4th, 2002 19:14
Ryan Buterbaugh, Martin Honnen, Brian Williams, Divisionsdommmerforeningen DDF93,


http://www.faqts.com/knowledge-base/view.phtml/aid/1691/fid/125/ 
explains how (if at all) it is possible to access the client's ip 
address.
You can (with NN4) attempt to send that data from a form but the 
browser warns the user that he is about to send a form via email and 
asks for his confirmation to do so.
<HTML>
<HEAD>
<TITLE>
ip address submission
</TITLE>
<STYLE>
#formLayer { position: absolute; visibility: hidden; }
</STYLE>
<SCRIPT>
function sendIP () {
  if (navigator.appName == 'Netscape'
      && navigator.javaEnabled()) {
    document.formLayer.document.formName.ip.value = 
      java.net.InetAddress.getLocalHost().getHostAddress();
    document.formLayer.document.formName.submit1.click();
  }
}
</SCRIPT>
</HEAD>
<BODY ONLOAD="sendIP()">
<DIV ID="formLayer">
<FORM NAME="formName"
      ACTION="mailto: whomever@whereever.tld"
      METHOD="post"
      ENCTYPE="text/plain"
>
<INPUT TYPE="text" NAME="ip">
<INPUT TYPE="submit" NAME="submit1">
</FORM>
</DIV>
</BODY>
</HTML>
It is however best to use server side methods to log ip addresses.