多语言代码错误

发布于 2024-11-04 08:34:54 字数 2055 浏览 1 评论 0原文

这是我的代码

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

 <script src="http://jquery-translate.googlecode.com/files/jquery.translate-1.3.7.min.js"></script>

<script type="text/javascript">

    jQuery(function($) { //when DOM is ready

       // $('body').css('height', '100px');


        $.translate(function() {  //when the Google Language API is loaded

            function translateTo(destLang) { //this can be declared in the global scope too if you need it somewhere else
               // alert('lang' + destLang);

                $('body').translate('english', destLang, {   //translate from english to the selected language
                    not: '.jq-translate-ui',  //by default the generated element has this className
                    fromOriginal: true   //always translate from english (even after the page has been translated)
                });
            }


            //you can generate other controls as well, not just a dropdown:
            $.translate.ui('ul', 'li', 'span')
      .appendTo('body')    //insert the element to the page
      .css({ 'color': 'blue', 'background-color': 'white' })
      .find('span')
      .css('cursor', 'pointer')
      .click(function() {   //when selecting another language

          translateTo($(this).text());

          //$.cookie('destLang', $(this).text());
          // set a cookie to remember the selected language
          // see: http://plugins.jquery.com/project/Cookie

          return false; //prevent default browser action
      });



             var destLang = $.cookie('destLang'); //get previously translated language

            if (destLang)  //if it was set then
                translateTo(destLang);


        }); //end of Google Language API loaded

    });  //end of DOM ready
</script>

I m getting error at line
    var destLang = $.cookie('destLang');

错误是:

Microsoft JScript 运行时错误:对象不支持此属性或方法

请帮助我。

this is my code

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

 <script src="http://jquery-translate.googlecode.com/files/jquery.translate-1.3.7.min.js"></script>

<script type="text/javascript">

    jQuery(function($) { //when DOM is ready

       // $('body').css('height', '100px');


        $.translate(function() {  //when the Google Language API is loaded

            function translateTo(destLang) { //this can be declared in the global scope too if you need it somewhere else
               // alert('lang' + destLang);

                $('body').translate('english', destLang, {   //translate from english to the selected language
                    not: '.jq-translate-ui',  //by default the generated element has this className
                    fromOriginal: true   //always translate from english (even after the page has been translated)
                });
            }


            //you can generate other controls as well, not just a dropdown:
            $.translate.ui('ul', 'li', 'span')
      .appendTo('body')    //insert the element to the page
      .css({ 'color': 'blue', 'background-color': 'white' })
      .find('span')
      .css('cursor', 'pointer')
      .click(function() {   //when selecting another language

          translateTo($(this).text());

          //$.cookie('destLang', $(this).text());
          // set a cookie to remember the selected language
          // see: http://plugins.jquery.com/project/Cookie

          return false; //prevent default browser action
      });



             var destLang = $.cookie('destLang'); //get previously translated language

            if (destLang)  //if it was set then
                translateTo(destLang);


        }); //end of Google Language API loaded

    });  //end of DOM ready
</script>

I m getting error at line
    var destLang = $.cookie('destLang');

error is :

Microsoft JScript runtime error: Object doesn't support this property or method

Please help me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无畏 2024-11-11 08:34:54

它需要 jQuery cookie 插件: http://plugins.jquery.com/project/Cookie

It requires jQuery cookie plugin: http://plugins.jquery.com/project/Cookie

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文