JavaScript Detect Country And Redirect

Here is my code, but it's not working.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="http://api.wipmania.com/jsonp?callback.js"></script>
<script type="text/javascript">
switch(country_code()){
case "IN" :
        document.location.href = "http://xxxxxxxx.biz/theme.php";
        break;
}
</script> 
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
</html>

I want to detect the user's country and redirect them appropriately.

Answer:1

You are using the wipmania link wrong it needs to have the name of a function in it that can be executed. You can use it in two ways one through an jsonp ajax call with jquery:

$.ajax({
   url:"http://api.wipmania.com/jsonp?callback=?",
   dataType:"jsonp"
}).done(function(data){
     switch(data.address.country_code){
        case "IN" :
           document.location.href = "http://xxxxxxxx.biz/theme.php";
        break;
     }      
});

or create a function in your code and then use the name of that function in the wipmania link

<script>
function determineCountry(data){
   switch(data.address.country_code){
      case "IN" :
         document.location.href = "http://xxxxxxxx.biz/theme.php";
      break;
   }    
}
</script>
<script type="text/javascript" src="http://api.wipmania.com/jsonp?callback=determineCountry"></script>
Answer:2

function showwaitmsg() { $("#wait").fadeIn(); return true; } function hidewaitmsg() { $("#wait").fadeOut(); } $("a:contains('Test1')").bind("click", function ...

function showwaitmsg() { $("#wait").fadeIn(); return true; } function hidewaitmsg() { $("#wait").fadeOut(); } $("a:contains('Test1')").bind("click", function ...

  1. make image visible using javascript
  2. make div visible using jquery
  3. make control visible using javascript
  4. make checkbox visible using javascript
  5. make panel visible using javascript
  6. make panel visible using jquery
  7. make control visible using jquery
  8. make textbox visible using jquery
  9. make textbox visible using javascript
  10. make button visible using jquery
  11. make image visible using jquery
  12. make label visible using jquery
  13. make a div visible using javascript
  14. make asp panel visible using javascript
  15. make a label visible using javascript
  16. make sentences using visible
  17. make asp.net control visible using javascript

So I have a menu on a screen where there are several identical boxes - the only difference is that the boxes are numbered differently. <div id="1"> <select name="option1"> &...

So I have a menu on a screen where there are several identical boxes - the only difference is that the boxes are numbered differently. <div id="1"> <select name="option1"> &...

I'm trying to check when a div is reached from scrollbar with jquery. I read some similar question on stackoverflow, but all are on one div only. I have 4 div, with height: 100% and I want know when ...

I'm trying to check when a div is reached from scrollbar with jquery. I read some similar question on stackoverflow, but all are on one div only. I have 4 div, with height: 100% and I want know when ...

I'm trying to create a stripe customer using parse but can't seem to get the customer.id value from the response. var newCustomer; Stripe.Customers.create( card: request.params.cardToken, ...

I'm trying to create a stripe customer using parse but can't seem to get the customer.id value from the response. var newCustomer; Stripe.Customers.create( card: request.params.cardToken, ...

  1. creating stripe customer
  2. stripe creating customer object