2 Replies - 525 Views - Last Post: 27 January 2014 - 02:55 PM

#1 jase81  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 120
  • Joined: 02-March 09

Geofencing a webpage

Posted 22 January 2014 - 04:26 PM

Hi,

I am looking for a way to use HTML5 geolocation to find where the user is in the world and then display page elements based on the result.

I am only looking at country level accuracy. If someone is in the US, I'll display a certain element, as opposed to someone in Australia who would see something different.

This seems to be a pretty common function for YouTube and TV channels who only allow their content to be viewed in certain regions.

Any help would be greatly appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: Geofencing a webpage

#2 jase81  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 120
  • Joined: 02-March 09

Re: Geofencing a webpage

Posted 23 January 2014 - 04:23 PM

So I found this javascript library which seems to be a great way of determining a users location based on HTML5 geolocation, with a fallback to the users IP address. Perfect for determining the visitors country of origin. (https://github.com/onury/geolocator)

What I need to do now, is check a list of values to determine what should be shown. For example:

Look in this (data structure) and see what the corresponding value is for the users country.
If the value is "A" embed this youtube link, else embed this link.

Any help how I can implement this in HTML5/Javascript?
Was This Post Helpful? 0
  • +
  • -

#3 ArtificialSoldier  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 383
  • View blog
  • Posts: 1,383
  • Joined: 15-January 14

Re: Geofencing a webpage

Posted 27 January 2014 - 02:55 PM

It sounds like you need quite a bit of Javascript code for that kind of thing, rather than server-side code. Just keep in mind that since it's all in Javascript you can't necessarily trust what it says, the user could change that.

One option might be to get the location with Javascript, and then send an ajax request to the server with the country and have the server return the appropriate content for the page.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1