Google
 
Welcome to RustySpigot, simple solutions for complex problems

main page

blog

forum


Downloads:

Remote Access
Go Desktop
PcNow download
GoToMyPc Download

Conferencing
FreeChat

ISPs
NetZero Review
Coupon Codes
Printer friendly version

Detecting visitors country using Javascript

About

Whilst trying to work out how to show location based ads on my site I thought of a way to do it using just Javascript. The idea is to detect the location based on their computers time different to GMT.

Implementation

The following code will detect if a visitor is from America:

<script> var now = new Date(); var off = (now.getTimezoneOffset()); if (off == 240 | off == 300 | off ==360 | off ==400) { document.write("American ad code"); } </script>


Further Info

The following image displays the different time zones:







Email to a friend | Groovyweb | Printer friendly version | Link to this page | Terms of Use | Contact
Unless otherwise noted, content on this site is licensed under Creative Commons Attribution 2.5| webmasters/Javascript Location Detection.htm was last modified on 2008-07-22 08:24:13