admin管理员组

文章数量:1391792

I was (trying to) load jQuery 1.9.1 un-minified from CDN: "Uncaught TypeError: Cannot call method 'call' of undefined jquery-1.9.1.js:648". So I updated the reference, and am apparently getting an equivalent error, now for minified:

Uncaught TypeError: Cannot call method 'call' of undefined jquery-1.11.0.min.js:2
n.extend.each jquery-1.11.0.min.js:2
(anonymous function) site.js:26
j jquery-1.11.0.min.js:2
k.fireWith jquery-1.11.0.min.js:2
n.extend.ready jquery-1.11.0.min.js:2
K jquery-1.11.0.min.js:2

The page is at ; the first SCRIPT tag is:

<script src="//code.jquery/jquery-1.11.0.min.js"></script>

(The page is POSH plus CSS styling and a light touch of JavaScript dust; it's simple by modern webapp standards...)

--EDIT--

Regarding my code, the page has, as its only script contents:

    <script src="//code.jquery/jquery-1.11.0.min.js"></script>
    <script src="/media/js/site.js"></script>

        <script>
                        function slideshow()
            {
            var width = (jQuery(window).width()  - 70) * .8;
            var factor = width / 1024;
            var height = 420 * factor;
            jQuery('#slideshow').attr('height', height + 'px');
            jQuery('#slideshow').attr('width', width + 'px');
            };
        slideshow();
        jQuery(window).resize(slideshow);
        </script>

The site.js file has:

/**
 * Override jQuery.fn.init to guard against XSS attacks.
 *
 * See 
 */
(function () {
  var jquery_init = jQuery.fn.init;
  jQuery.fn.init = function (selector, context, rootjQuery) {
    // If the string contains a "#" before a "= 0) {
        var bracket_position = selector.indexOf(' hash_position) {
          throw 'Syntax error, unrecognized expression: ' + selector;
        }
      }
    }
    return jquery_init.call(this, selector, context, rootjQuery);
  };
  jQuery.fn.init.prototype = jquery_init.prototype;
})();

jQuery(function()
    {
    jQuery.each(jQuery('h1').add('h2').add('h3').add('h4').add('h5').add('h6').add('ul#navigation')).function(index, element)
        {
        var bounds = jQuery(element).offset();
        var image_left = bounds.left;
        var image_top = bounds.top + bounds.height;
        var image = jQuery('');
        image.style.position = 'absolute';
        image.style.top = image_top + 'px';
        image.style.left = image_left + 'px';
        }
   function set_search_width()
        {
        var offset = 950;
        var width = jQuery(window).width() - offset;
        jQuery('#menu-search').css('max-width', width + 'px');
        jQuery('#menu-search').css('width', width + 'px');
        jQuery('#query').width(width - 80);
        }
    jQuery(window).resize(set_search_width);
    set_search_width();
    });
sfHover = function()
    {
    var sfEls =
    document.getElementById('nav').getElementsByTagName('li');
    for(var index = 0; index 

/**
 * Override jQuery.fn.init to guard against XSS attacks.
 *
 * See 
 */
(function () {
  var jquery_init = jQuery.fn.init;
  jQuery.fn.init = function (selector, context, rootjQuery) {
    // If the string contains a "#" before a "<", treat it as invalid HTML.
    if (selector && typeof selector === 'string') {
      var hash_position = selector.indexOf('#');
      if (hash_position >= 0) {
        var bracket_position = selector.indexOf('<');
        if (bracket_position > hash_position) {
          throw 'Syntax error, unrecognized expression: ' + selector;
        }
      }
    }
    return jquery_init.call(this, selector, context, rootjQuery);
  };
  jQuery.fn.init.prototype = jquery_init.prototype;
})();

jQuery(function()
    {
    jQuery.each(jQuery('h1').add('h2').add('h3').add('h4').add('h5').add('h6').add('ul#navigation')).function(index, element)
        {
        var bounds = jQuery(element).offset();
        var image_left = bounds.left;
        var image_top = bounds.top + bounds.height;
        var image = jQuery('<img src="/media/images/foldback.png">');
        image.style.position = 'absolute';
        image.style.top = image_top + 'px';
        image.style.left = image_left + 'px';
        }
   function set_search_width()
        {
        var offset = 950;
        var width = jQuery(window).width() - offset;
        jQuery('#menu-search').css('max-width', width + 'px');
        jQuery('#menu-search').css('width', width + 'px');
        jQuery('#query').width(width - 80);
        }
    jQuery(window).resize(set_search_width);
    set_search_width();
    });
sfHover = function()
    {
    var sfEls =
    document.getElementById('nav').getElementsByTagName('li');
    for(var index = 0; index < sfEls.length; index++)
        {
        sfEls[i].onmouseover = function()
            {
            this.className += " sfhover";
            }
        sfEls[i].onmouseout = function()
            {
            this.className = this.className.replace(new RegExp(
              " sfhover\\b"), "");
            }
        }
    }
if (window.attachEvent)
    {
    window.attachEvent("onload", sfHover);
    }

I was (trying to) load jQuery 1.9.1 un-minified from CDN: "Uncaught TypeError: Cannot call method 'call' of undefined jquery-1.9.1.js:648". So I updated the reference, and am apparently getting an equivalent error, now for minified:

Uncaught TypeError: Cannot call method 'call' of undefined jquery-1.11.0.min.js:2
n.extend.each jquery-1.11.0.min.js:2
(anonymous function) site.js:26
j jquery-1.11.0.min.js:2
k.fireWith jquery-1.11.0.min.js:2
n.extend.ready jquery-1.11.0.min.js:2
K jquery-1.11.0.min.js:2

The page is at http://ccachicago.pragmatometer.; the first SCRIPT tag is:

<script src="//code.jquery./jquery-1.11.0.min.js"></script>

(The page is POSH plus CSS styling and a light touch of JavaScript dust; it's simple by modern webapp standards...)

--EDIT--

Regarding my code, the page has, as its only script contents:

    <script src="//code.jquery./jquery-1.11.0.min.js"></script>
    <script src="/media/js/site.js"></script>

        <script>
                        function slideshow()
            {
            var width = (jQuery(window).width()  - 70) * .8;
            var factor = width / 1024;
            var height = 420 * factor;
            jQuery('#slideshow').attr('height', height + 'px');
            jQuery('#slideshow').attr('width', width + 'px');
            };
        slideshow();
        jQuery(window).resize(slideshow);
        </script>

The site.js file has:

/**
 * Override jQuery.fn.init to guard against XSS attacks.
 *
 * See http://bugs.jquery./ticket/9521
 */
(function () {
  var jquery_init = jQuery.fn.init;
  jQuery.fn.init = function (selector, context, rootjQuery) {
    // If the string contains a "#" before a "= 0) {
        var bracket_position = selector.indexOf(' hash_position) {
          throw 'Syntax error, unrecognized expression: ' + selector;
        }
      }
    }
    return jquery_init.call(this, selector, context, rootjQuery);
  };
  jQuery.fn.init.prototype = jquery_init.prototype;
})();

jQuery(function()
    {
    jQuery.each(jQuery('h1').add('h2').add('h3').add('h4').add('h5').add('h6').add('ul#navigation')).function(index, element)
        {
        var bounds = jQuery(element).offset();
        var image_left = bounds.left;
        var image_top = bounds.top + bounds.height;
        var image = jQuery('');
        image.style.position = 'absolute';
        image.style.top = image_top + 'px';
        image.style.left = image_left + 'px';
        }
   function set_search_width()
        {
        var offset = 950;
        var width = jQuery(window).width() - offset;
        jQuery('#menu-search').css('max-width', width + 'px');
        jQuery('#menu-search').css('width', width + 'px');
        jQuery('#query').width(width - 80);
        }
    jQuery(window).resize(set_search_width);
    set_search_width();
    });
sfHover = function()
    {
    var sfEls =
    document.getElementById('nav').getElementsByTagName('li');
    for(var index = 0; index 

/**
 * Override jQuery.fn.init to guard against XSS attacks.
 *
 * See http://bugs.jquery./ticket/9521
 */
(function () {
  var jquery_init = jQuery.fn.init;
  jQuery.fn.init = function (selector, context, rootjQuery) {
    // If the string contains a "#" before a "<", treat it as invalid HTML.
    if (selector && typeof selector === 'string') {
      var hash_position = selector.indexOf('#');
      if (hash_position >= 0) {
        var bracket_position = selector.indexOf('<');
        if (bracket_position > hash_position) {
          throw 'Syntax error, unrecognized expression: ' + selector;
        }
      }
    }
    return jquery_init.call(this, selector, context, rootjQuery);
  };
  jQuery.fn.init.prototype = jquery_init.prototype;
})();

jQuery(function()
    {
    jQuery.each(jQuery('h1').add('h2').add('h3').add('h4').add('h5').add('h6').add('ul#navigation')).function(index, element)
        {
        var bounds = jQuery(element).offset();
        var image_left = bounds.left;
        var image_top = bounds.top + bounds.height;
        var image = jQuery('<img src="/media/images/foldback.png">');
        image.style.position = 'absolute';
        image.style.top = image_top + 'px';
        image.style.left = image_left + 'px';
        }
   function set_search_width()
        {
        var offset = 950;
        var width = jQuery(window).width() - offset;
        jQuery('#menu-search').css('max-width', width + 'px');
        jQuery('#menu-search').css('width', width + 'px');
        jQuery('#query').width(width - 80);
        }
    jQuery(window).resize(set_search_width);
    set_search_width();
    });
sfHover = function()
    {
    var sfEls =
    document.getElementById('nav').getElementsByTagName('li');
    for(var index = 0; index < sfEls.length; index++)
        {
        sfEls[i].onmouseover = function()
            {
            this.className += " sfhover";
            }
        sfEls[i].onmouseout = function()
            {
            this.className = this.className.replace(new RegExp(
              " sfhover\\b"), "");
            }
        }
    }
if (window.attachEvent)
    {
    window.attachEvent("onload", sfHover);
    }

Share Improve this question edited Mar 10, 2014 at 15:57 Christos Hayward asked Mar 10, 2014 at 15:51 Christos HaywardChristos Hayward 5,99317 gold badges61 silver badges116 bronze badges 3
  • what does site.js:26 include? – mamdouh alramadan Commented Mar 10, 2014 at 15:54
  • We would need to see where within your code this problem starts. – Kevin B Commented Mar 10, 2014 at 15:54
  • 2 jQuery.each(jQuery('h1').add('h2').add('h3').add('h4').add('h5').add('h6').add('ul#navigation')).function(index, element) { ??? Check jQuery.each() syntax. Anyway, you should use here jQuery.fn.each() – A. Wolff Commented Mar 10, 2014 at 15:55
Add a ment  | 

2 Answers 2

Reset to default 3

You have incorrect syntxis

What do you whant to do with ?

jQuery(function()
    {
    jQuery.each(jQuery('h1').add('h2').add('h3').add('h4').add('h5').add('h6').add('ul#navigation')).function(index, element)
        {
        var bounds = jQuery(element).offset();
        var image_left = bounds.left;
        var image_top = bounds.top + bounds.height;
        var image = jQuery('<img src="/media/images/foldback.png">');
        image.style.position = 'absolute';
        image.style.top = image_top + 'px';
        image.style.left = image_left + 'px';
        }
   function set_search_width()
        {
        var offset = 950;
        var width = jQuery(window).width() - offset;
        jQuery('#menu-search').css('max-width', width + 'px');
        jQuery('#menu-search').css('width', width + 'px');
        jQuery('#query').width(width - 80);
        }
    jQuery(window).resize(set_search_width);
    set_search_width();
    });

maybe code below is what you want ? ( find elements, i think it is better use plex selector, and apply function to each element )

jQuery('h1').add('h2').add('h3').add('h4').add('h5').add('h6').add('ul#navigation').each(function(index, element)
    {
    var bounds = jQuery(element).offset();
    var image_left = bounds.left;
    var image_top = bounds.top + bounds.height;
    var image = jQuery('<img src="/media/images/foldback.png">');
    image.style.position = 'absolute';
    image.style.top = image_top + 'px';
    image.style.left = image_left + 'px';
    });

The offending line is: site.js line 26

if should be something like

jQuery.each(jQuery('h1').add('h2'), function(index, element) { ... })

not

jQuery.each(jQuery('h1').add('h2')).function(index, element) { ... }

本文标签: