Jump to content

Submit Browser Info


Recommended Posts

Building visitor statistics is a very common activity among webmasters, so nothing new under the sun here...

Most of them do this through analysis of the webserver logs however. This puts minimal requirements on the browser, and happens transparently while the visitor browses the website. Sometimes however you don't have access to the serverlogs, for example when you are using a low-cost webhost. In these cases it may be a good solution to aquire this information through forms.

The key technology you need is JavaScript. You need JavaScript to automatically fill a hidden form field, with information from the JavaScript object "navigator.userAgent".

Note however two important things:

- The useragent is often "spoofed", that is the browser disguises itself as another browser, either to fool statistics or to make badly programmed websites (see next point) behave properly.

- The useragent is not the right place to search when you need to know the capabilities of a browser. Badly programmed websites may look at the useragent to determine if a browser for example supports a certain JavaScript function. This will break when the user uses an unknown browser, an unexpected newer version, or has disabled certain features of his browser. You will need "object detection" if you need to know your visitor's capabilities.

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 weeks later...
is there a javascript function to determine a user's IP address when they submit a form?

Not in pure JavaScript. But you can use a combination of JavaScript and SSI. SSI is an old server-side "programming" language (older than ASP for example) which is supported by most webservers. The fact that it is server-side means you are not dependend on compatibility with different kinds of webbrowsers, if it works on your webserver then it will work with any webbrowser viewing your website.

Following is an example code to display the visitor's IP address:

alert("IP address: <!--#echo var="REMOTE_ADDR"-->");

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy