【问题标题】:geoPlugin undefine variable with IEgeoPlugin 用 IE 取消定义变量
【发布时间】:2012-09-28 01:04:20
【问题描述】:

我有几个网站使用geoPlugin,在 2012 年 9 月 24 日 Microsoft 的 IE 更新之后,我遇到了一些奇怪的问题。我首先注意到我的 nivo 滑块没有显示在我的主页上,所以我在控制台中挖了一个

SCRIPT5009: 'geoplugin_countryCode' is undefined

然后我在谷歌浏览器中调试了同一个页面,那里一切正常。我试图破译有关该更新的 KB2744842 公告

这是我的 javascript:

<script src="https://ssl.geoplugin.net/javascript.gp" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function() {
        var country = geoplugin_countryCode();

        if(country === 'CA'){
            $('#notification').html('<div class="attention" style="display: none;">You are in Canada</div>');
            $('.attention').fadeIn('slow');
            $('html, body').animate({ scrollTop: 0 }, 'slow');
        }else if(country != 'US'){
            $('#notification').html('<div class="attention" style="display: none;">You are in the USA</div>');
            $('.attention').fadeIn('slow');
            $('html, body').animate({ scrollTop: 0 }, 'slow');
        }else{
            //nothing stupid IE
        }

    });
    $('.geoClose').live('click', function() {
        console.log('geoplugin notify closed');
        document.cookie = 'geoClose=true;'
    });
</script>

HTML:

<div id="wrapper">
  <div id="header">Header Text</div>
  <div id="notification"></div>
  <div id="content">Content Here!</div>
  <div id="footer"></div>
</div>​

【问题讨论】:

    标签: javascript internet-explorer-8 internet-explorer-9 cross-domain


    【解决方案1】:

    geoPlugin 最近更改了一些关于 SSL 请求的策略,显然 IE 不会遵循实现的重定向,而其他浏览器会。

    结果代码:

    <script src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script>
    <script src="http://www.geoplugin.net/statistics.gp" type="text/javascript"></script>
    <!--<script src="https://ssl.geoplugin.net/javascript.gp" type="text/javascript"></script>-->
    <script type="text/javascript">
    //<![CDATA[
        $(document).ready(function() {
            var country = geoplugin_countryCode();
    
            if(country === 'CA'){
                $('#notification').html('<div class="attention" style="display: none;">You are in Canada</div>');
                $('.attention').fadeIn('slow');
                $('html, body').animate({ scrollTop: 0 }, 'slow');
            }else if(country != 'US'){
                $('#notification').html('<div class="attention" style="display: none;">You are in the USA</div>');
                $('.attention').fadeIn('slow');
                $('html, body').animate({ scrollTop: 0 }, 'slow');
            }else{
                //nothing stupid IE
            }
    
        });
        $('.geoClose').live('click', function() {
            console.log('geoplugin notify closed');
            document.cookie = 'geoClose=true;'
        });
    //]]>
    </script>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-01
      • 1970-01-01
      • 2015-11-23
      • 1970-01-01
      • 2019-08-26
      • 2018-09-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多