webkit 中的意外令牌非法 [英] Unexpected token ILLEGAL in webkit
问题描述
// if the box is outside the window, move it to the end
function checkEdge() {
var windowsLeftEdge = $('#window').position().left;
$('.box').each( function(i, box) {
// right edge of the sliding box
var boxRightEdge = $(box).position().left + $(box).width();
// position of last box + width + 10px
var newPosition = getNewPosition();
if ( parseFloat(boxRightEdge) < parseFloat(windowsLeftEdge) ) {
$(box).css('left', newPosition);
$(box).remove().appendTo('#window');
first = $('.box:first').attr('class');
}
});
} //Uncaught SyntaxError: Unexpected token ILLEGAL Occurs Here
// arrange the boxes to be aligned in a row
function arrangeBoxes() {
$('.box').each( function(i, item) {
var position = $('#window').position().left + i * ( $(item).width());
$(item).css('left', position+'px')
});
}
// shifts all the boxes to the left, then checks if any left the window
function shiftLeft() {
$('.box').animate({'left' : "-=100px"}, 5000, 'linear', checkEdge());
}
// returns the new location for the box that exited the window
function getNewPosition() {
return $('.box:last').position().left + $('.box:last').outerWidth();
}
$(window).load(function() {
arrangeBoxes();
shiftLeft();
setInterval('shiftLeft()', 5000);
$('#gallery-slideshow').nivoSlider({
effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
slices:15,
animSpeed:500, //Slide transition speed
pauseTime:3000,
startSlide:0, //Set starting Slide (0 index)
directionNav:true, //Next & Prev
directionNavHide:true, //Only show on hover
controlNav:false, //1,2,3...
keyboardNav:false, //Use left & right arrows
pauseOnHover:false, //Stop animation while hovering
manualAdvance:false, //Force manual transitions
captionOpacity:0, //Universal caption opacity
beforeChange: function(){},
afterChange: function(){},
slideshowEnd: function(){}, //Triggers after all slides have been shown
lastSlide: function(){}, //Triggers when last slide is shown
afterLoad: function(){} //Triggers when slider has loaded
});
});
$(document).ready(function(){
$('.class-table tr').click(function(){
window.location=$(this).find("a").attr("href"); return false;
});
$('.special-workshop').click(function(){
window.location=$(this).find("a").attr("href"); return false;
});
});
我在上面提到的行上收到一个 Uncaught SyntaxError: Unexpected token ILLEGAL.它仅出现在 Google Chrome 和 Safari 中.它适用于 Firefox,同样的代码适用于这个 JSBin (http://jsbin.com/uceqi/18)
I am getting an Uncaught SyntaxError: Unexpected token ILLEGAL on the line mentioned above. It occurs only in Google Chrome and Safari. It works in Firefox and the same code works on this JSBin (http://jsbin.com/uceqi/18)
这是怎么回事?
在 Stackoverflow 上有很多关于这个问题的参考,但似乎没有一个适用于这种情况.
There are numerous references to this problem on Stackoverflow but none of them seem to apply to this situation.
如果它有帮助,JSLint 也会在该行字符 2 上抛出并出错第 22 行字符 2 的问题:意外的 ' '."
If it helps JSLint also throws and error on that line character 2 "Problem at line 22 character 2: Unexpected ''."
推荐答案
删除该区域周围的所有不可见字符(空格),然后再试一次.
Delete all invisible characters (whitespace) around that area, then give it another try.
我在 Safari 中看到过复制/粘贴代码时出现的错误.您可以选择一些无效(不幸的是不可见)的字符.
I've seen that error in Safari when copy/pasting code. You can pick up some invalid (and unfortunately invisible) characters.
从 jsFiddle 复制时经常发生在我身上.
Used to happen to me a lot when copying from jsFiddle.
这篇关于webkit 中的意外令牌非法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!