I'm trying to redirect a user with window.location based on geolocation latitude and longitude coordinates. I only want the visitor to have access to my page when they're lat and long = 36.24, 76.21. I'm currently only checking against latitude, but will fix that later. Anyways, its not redirecting to the proper page. I can throw any value in the numlat variable and it will still redirect to work.php while it should redirect to didntwork.php if it doesn't match 36.24. Any ideas on what I'm doing wrong? Thanks!
Here's my current code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Your Address:</title>
<script type="text/javascript">
navigator.geolocation.getCurrentPosition(function(position) {
lat = position.coords.latitude;
lang = position.coords.longitude;
var numlat=lat.toFixed(2);
if(numlat=36.24)
{
window.location.href = "work.php";
}
else
{
window.location.href = "didntwork.php";
}
});
</script
Thanks for the answer and explanation. I thought I tried the double == last night but it was getting late. Changing this worked!
=is for assignment,==is for comparison.