javascript - 部分 javascripts 在浏览器中被 chop

标签 javascript jquery sharepoint-2007

问候

我的一个客户 javascript 文件失败。我找到了原因,但这个发现让我非常困惑,因为我从未见过这样的事情。

问题在于,当浏览器读取脚本源并输入包含 543 行代码的特定自定义 .js 文件时,它只会读取到第 502 行,即 if (isValidWidthChange) { 但让我感到困惑的是,当我在 IE 中使用开发人员工具并在 FireFox 中使用 firebug 并使用他们的脚本调试工具时,当它到达第 502 行时,javascript 会像这样被切断 - if (isValidWidthChan

如果(isValidWidthChange){

如果(isValidWidthChan

谁能给我一个逻辑解释为什么会发生这种情况?

我可以说这么多,我在文件中添加了一些东西,但是我在开始之前备份了原始文件,这实际上是我将网站设置为使用后仍然出现的错误原始文件。

我已经尝试了很多次 IISRESET。我试过从健康的环境中复制文件。我已经清除了浏览器和服务器上的所有缓存。但它仍然出现。

不是自己开发的,是第三方的产品。但这以前从未发生过。

错误发生的代码片段

(function($) {
    // jQuery autoGrowInput plugin by James Padolsey
    // See related thread: http://stackoverflow.com/questions/931207/is-there-a-jquery-autogrow-plugin-for-text-fields
    $.fn.autoGrowInput = function(o) {
        o = $.extend({
            maxWidth: 1000,
            minWidth: 0,
            comfortZone: 70
        }, o);
        this.filter('input:text').each(function() {
            var minWidth = o.minWidth || $(this).width(),
                val = '',
                input = $(this),
                testSubject = $('<tester/>').css({
                    position: 'absolute',
                    top: -9999,
                    left: -9999,
                    width: 'auto',
                    fontSize: input.css('fontSize'),
                    fontFamily: input.css('fontFamily'),
                    fontWeight: input.css('fontWeight'),
                    letterSpacing: input.css('letterSpacing'),
                    whiteSpace: 'nowrap'
                }),
                check = function() {
                    if (val === (val = input.val())) { return; }
                    // Enter new content into testSubject
                    var escaped = val.replace(/&/g, '&amp;').replace(/\s/g, '&nbsp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
                    testSubject.html(escaped);
                    // Calculate new width + whether to change
                    var testerWidth = testSubject.width(),
                        newWidth = (testerWidth + o.comfortZone) >= minWidth ? testerWidth + o.comfortZone : minWidth,
                        currentWidth = input.width(),
                        isValidWidthChange = (newWidth < currentWidth && newWidth >= minWidth)
                                             || (newWidth > minWidth && newWidth < o.maxWidth);
                    // Animate width
                    if (isValidWidthChange) { // This is where it stops
                        input.width(newWidth);
                    }
                };
            testSubject.insertAfter(input);
            $(this).bind('keyup keydown blur update', check);
        });
        return this;
    };
})(jQuery);

最佳答案

可能是编码问题,请确保所有脚本中没有特殊字符;

查看 Owns 和 Rate 附近的字符,这些字符将被浏览器忽略,脚本将根据它们的数量被 chop

/*
    Mapping GUI to event types
    Click - clickEvents
    Purchase -purchaseEvents
    Consume - consumeEvents
    Recommended - clickedRecommended
    Rendered - renderedEvents
    Rate ײateEvents
    Blacklist - blacklistEvents
    Owns ׯwnsEvents
    Total

*/ 

关于javascript - 部分 javascripts 在浏览器中被 chop ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5883669/

相关文章:

asp.net - 是否可以在不影响该服务的所有用户的情况下调试 IIS?

unit-testing - 如何在 sharepoint 2007 上使用单元测试框架?

sharepoint - 将多个功能打包到一个 WSP 解决方案文件中

javascript - 如何从服务器端访问通过 Jquery.getJSON 发送的数据?

javascript - 如何让导航栏顺畅流动?

javascript - 将 SCSS 编译成 CSS 并同时将 ES6 转译为 ES5

Java JSP Jquery AJAX Servlet

javascript - 使用 JQuery 包装元素

javascript - 包含文本区域的行跨度表 td

javascript - HTML5视频自定义控件: How to show the current frame of the video while dragging the seekbar