Results 1 to 4 of 4

Thread: OnLoad detect country and redirect script

  1. #1
    Join Date
    Mar 2010
    Thanked 0 Times in 0 Posts

    Default OnLoad detect country and redirect script

    Hi guys,

    i hope you can help. I am looking for a script that will detect whether or not the user is based in the UK or Internationally and then change the page according to which geographical location the user is in.

    Can you help at all please? Thanks

  2. #2
    Join Date
    Jul 2008
    Derbyshire, UK
    Thanked 599 Times in 575 Posts
    Blog Entries


    Google is your friend:

    However, you might want to avoid doing this as its not necessarily 100% reliable. I would say the better option would be to provide an easily visible country selection menu so the user can choose their own country - or use a combination of the 2 - - what if a visitor was travelling abroad and wanted to view content for their own region? Without the option to change they'd be pretty stuck.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. #3
    Join Date
    Jan 2011
    Southeastern CT
    Thanked 32 Times in 32 Posts


    Last edited by ajfmrf; 01-12-2013 at 12:23 AM. Reason: add more to post


  4. #4
    Join Date
    Mar 2006
    Illinois, USA
    Thanked 690 Times in 678 Posts


    I've used GeoIP and I like it. For countries it should be reliable (90%+) and there are a few competing services out there that may also work.

    It will be a little work to set up, but it may help your website.

    However, I agree with Beverley that you need to be careful:
    1) It may make mistakes sometimes. Even if that's just 1% of users (and that would be lucky!) then you don't want them to have problems.
    2) Your physical location is not always useful information. People go on vacation, and they may want to buy something for when they return.
    3) If this has anything to do with languages, the languages people can read don't always correlate with location-- maybe they're recent immigrants, or maybe you don't have their native language available so they need to pick the next best option-- for example Hungarians might pick German, and you'd have very little chance knowing that.

    So... I suggest using the IP information as a first guess. I'm not sure I'd recommend using a redirect with it, but if you can actually integrate conditional content, that would be best. Or a redirect is fine as long as it isn't limiting or substantially different-- one page for people in the UK, and one page for others; but they have the same content overall.

    Then I think you MUST allow them an easy way to switch between the websites. If there are reasons that it might be a problem, inform the user. You shouldn't/can't rely on this information such as for tax purposes, etc., or anything important.

    And just for convenience-- for me while traveling I absolutely hate how Google doesn't let me choose my location for searches and attempts to "guess" what I want based on where I happen to be. It's hard to work around this (but there are options; I have an add-on for firefox now, for example), and there's really no reason it should be a problem. I like that it guesses my location and may be helpful if I want something local, but I hate that sometimes it limits what I can do. So again, make a first guess, and let the user do the rest.

    In fact, if this is important, you might consider having a one-time first page that asks them their location. You can use a locating script to guess for them and say "Are you in the UK?" or "Are you outside the UK?" based on what you know-- but then they can confirm this and you'll know the answer is right (and accurate for the individual, not their current physical location).

    That may sound excessive, but it is used fairly often for business websites. One that comes to mind is the FedEx website:
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Similar Threads

  1. How to detect iframe src after serverside redirect?
    By Birmingham in forum JavaScript
    Replies: 2
    Last Post: 07-17-2008, 09:39 AM
  2. Using body onload to redirect using images
    By remf in forum JavaScript
    Replies: 2
    Last Post: 07-30-2006, 04:11 PM
  3. current browser detect redirect script help
    By brent13a in forum JavaScript
    Replies: 3
    Last Post: 05-01-2005, 07:26 PM
  4. Detect Speed and Redirect
    By hldr in forum JavaScript
    Replies: 10
    Last Post: 04-23-2005, 08:00 PM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts