Internet Explorer 中的 Javascript 代码错误

标签 javascript jquery internet-explorer cross-browser

我的网络 + Jquery 插件在 Firefox、Chrome、Safari(win 和 Osx)和 Android 上也运行良好。但它在 Windows + Internet Explorer 中很糟糕,因为它不加载一些 js。我快要疯了,因为它适用于除 IE 之外的所有场景。

IE 向我显示 3 个错误警告。我的问题是。 IE 必须编译完善所有这 3 个错误才能显示正确的页面吗?例如,我有一个使用 jquery 的实时搜索,但它在 IE 上不起作用,因为它向我显示该代码的错误。

你能帮我验证这个“有效”代码吗?提前谢谢大家

    $(function() {
   // find all the input elements with title attributes
   $('input[title!=""]').hint(); 
   }
); 
(function ($) {
   $.fn.hint = function (blurClass) {
      if (!blurClass) {
         blurClass = 'blur'; }
      return this.each(function () {
         // get jQuery version of 'this'
         var $input = $(this), 
         // capture the rest of the variable to allow for reuse
         title = $input.attr('title'), 
         $form = $(this.form), 
         $win = $(window); function remove() {
            if ($input.val() === title && $input.hasClass(blurClass)) {
               $input.val('').removeClass(blurClass); }
            }
         // only apply logic if the element has the attribute
         if (title) {
            // on blur, set value to title attr if text is blank
            $input.blur(function () {
               if (this.value === '') {
                  $input.val(title).addClass(blurClass); }
               }
            ).focus(remove).blur(); // now change all inputs to title
            // clear the pre-defined text when form is submitted
            $form.submit(remove); $win.unload(remove); // handles Firefox's autocomplete
            }
         }
      ); }; }
)(jQuery); 
var options, a; 
jQuery(function() {
   var onAutocompleteSelect = function(value, 
   data) {
      window.open('ITEM.PRO?&token=#AVP'navegante'&S=' + value.substring(value.length - 4)); }
   options = {
      serviceUrl : 'JQUERY-#AVP$_SETLANG$.pro', 
      onSelect : onAutocompleteSelect, }; a = $('#query').autocomplete(options); }
); 

最佳答案

您示例中的下一段代码可能有一些错误:

原代码:

var options, a; 
jQuery(function() {
   var onAutocompleteSelect = function(value, 
   data) {
      window.open('ITEM.PRO?&token=#AVP'navegante'&S=' + value.substring(value.length - 4)); }
   options = {
      serviceUrl : 'JQUERY-#AVP$_SETLANG$.pro', 
      onSelect : onAutocompleteSelect, }; a = $('#query').autocomplete(options); }
); 

更改代码:

var options, a; 
jQuery(function() {
  var onAutocompleteSelect = function(value, data) {
    // in next line added plus signs before and after *navegante*
    window.open('ITEM.PRO?&token=#AVP'+navegante+'&S='+value.substring(value.length-4));
  }; // semicolon added
  options = {
    serviceUrl : 'JQUERY-#AVP$_SETLANG$.pro', 
    // in next line removed comma. I think: it generate error in IE
    onSelect : onAutocompleteSelect //, 
  };
  a = $('#query').autocomplete(options);
}); 

关于Internet Explorer 中的 Javascript 代码错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7468462/

相关文章:

javascript - 调用函数洞察函数/参数

javascript - 在 AngularJS 和 Bootstrap 的搜索框中生成结果

jquery - EA手机游戏网站问题?

javascript - 为什么我的 AJAX 响应包含 HTML 源代码?

css - IE8 在错误的位置寻找来自 css 的图像

javascript - Angular Ui 树递增是重复的

javascript - Socket.IO Broadcast 发出不起作用如何修复它,

javascript - 对 div 元素进行动画处理,改变其在 div 列表中的位置

Html Canvas - 对象不支持属性或方法 'remove'

javascript - 在 IE9 中调试带有 JavaScript 错误的网站 - 打开调试控制台修复错误