【发布时间】:2013-11-28 18:23:22
【问题描述】:
问候
我的一个客户 javascript 文件失败了。我找到了原因,但这个发现让我非常困惑,因为我从未见过这样的事情。
问题是,当浏览器读取脚本源并输入包含 543 行代码的特定自定义 .js 文件时,它只读取到第 502 行,即 if (isValidWidthChange) {,但让我感到困惑的是,当我在 IE 中使用开发人员工具,在 FireFox 中使用 firebug 并使用他们的脚本调试工具,当它到达第 502 行时,javascript 会像这样被切断 - if (isValidWidthChan
if (isValidWidthChange) {
if (isValidWidthChan
谁能给我一个逻辑解释为什么会发生这种情况?
我可以说这么多,我在文件中添加了一些东西,但我在开始之前备份了原始文件,这实际上是即使在我将网站设置为使用重新打开原始文件。
我已经尝试了很多次 IISRESET。我尝试从健康的环境中复制文件。我已经清除了浏览器和服务器上的所有缓存。但它仍然出现。
不是我自己开发的,它是第三方产品。但这从未发生过。
错误发生位置的codesn-p
(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, '&').replace(/\s/g, ' ').replace(/</g, '<').replace(/>/g, '>');
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);
【问题讨论】:
-
还有其他脚本加载吗?他们还好吗?
-
检查您的 http 响应(使用 firebug 或 httpfox)。服务器可能(出于某种原因)没有返回整个脚本。
-
@Daniel 在所有浏览器中都有。 @ppumkin 是的,还有其他脚本正在加载,它们工作得很好。
-
听起来像是服务器或 SharePoint 问题。尝试重命名
.js文件,看看是否有帮助。
标签: javascript jquery sharepoint-2007