-1

This is my code im not the most experienced in javascript.

var x = document.domain;

function myFunction() {

    if(x == "usa"){
      window.location = "usafile"
    }
    elseif(x == "canada"){
      window.location = "canadafile"
    }
}
ScottJShea
  • 7,041
  • 11
  • 44
  • 67

1 Answers1

1

You can look their ip up in any ip to location service (hostip.info, maxmind). This will be accurate most of the time.

Check this answer: How to get visitor's location (i.e. country) using javascript geolocation

Community
  • 1
  • 1
pearpages
  • 18,703
  • 1
  • 26
  • 27