Pergunta

As a novice at JS I am pretty happy to get a script with the MaxMind API working in webkit browsers, however, IE didn't want to come to the party (and I thought it was only CSS/HTML issues that plagued IE!)

The page that I am testing can be found here - http://www.ontrackdatarecovery.es/images/phone/130612-es-dynamic-phone-geoip.html

As you should be able to see, it works in Chrome etc, but not in IE (8). Any assistance is greatly appreciated!

Thanks

Foi útil?

Solução

Console says 'return' statement outside of function. Try changing that return statement to break

default:
    regionPhone = '<p>This is an IP from ' + userCountry + '</p>';
    break;

Outras dicas

In IE, the variable regionPhone is undefined. Apparently, this is due to your return statement (IE says: return statement outside of function), as Mark mentions.

How about wrapping your logic into $(function() {}) which will make sure the logic is run when the DOM is loaded. Also, it avoids having global variables.

Something like:

$(function() {
    var userRegion = geoip_region();
    var userCountry = geoip_country_code();
    var regionPhone;

    switch (userCountry) { 
    case "GB":
    var region = {};  
        // and so on

    $(".Regional-Phone").html(regionPhone);
    document.write('<p>Country: ' + userCountry + '<br>Region: ' + userRegion + '<br>City: ' + geoip_city() + '</p>');

});
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top