웹킷에 예기치 않은 토큰이 잘못되었습니다.
// 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 ) 에서 작동합니다.
무슨 일이야?
Stackoverflow에이 문제에 대한 많은 참조가 있지만이 상황에 적용되는 것은 없습니다.
도움이된다면 JSLint는 또한 해당 줄 문자 2에서 "문제 22 번째 줄 문자 2 : 예기치 않은 ''"오류를 발생시킵니다.
해당 영역 주변의 보이지 않는 문자 (공백)를 모두 삭제 한 다음 다시 시도하십시오.
코드를 복사 / 붙여 넣기 할 때 Safari에서 오류가 발생했습니다. 유효하지 않은 (그리고 안타깝게도 보이지 않는) 문자를 선택할 수 있습니다.
jsFiddle에서 복사 할 때 많이 발생했습니다.
It doesn't apply to this particular code example, but as Google food, since I got the same error message:
<script>document.write('<script src="…"></script>');</script>
will give this error but
<script>document.write('<script src="…"><'+'/script>');</script>
will not.
Further explanation here: Why split the <script> tag when writing it with document.write()?
I got the same error when the script file I was including container some special characters and when I was running in local moode (directly from local disk). I my case the solution was to explicitly tell the encoding:
<script src="my.js" charset="UTF-8"></script>
Note for anyone running Vagrant: this can be caused by a bug with their shared folders. Specify NFS for your shared folders in your Vagrantfile to avoid this happening.
Simply adding type: "nfs"
to the end will do the trick, like so:
config.vm.synced_folder ".", "/vagrant", type: "nfs"
Another possible cause for Googlers: Using additional units in a size like so:
$('#file_upload').uploadify({
'uploader' : '/uploadify/uploadify.swf',
'script' : '/uploadify/uploadify.php',
'cancelImg' : '/uploadify/cancel.png',
'folder' : '/uploads',
'queueID' : 'custom-queue',
'buttonImg': 'img/select-images.png',
'width': '351px'
});
Setting '351px' there gave me the error. Removing 'px' banished the error.
Also for the Google-fodder: check in your text editor whether the .js file is saved as Unicode and consider setting it to ANSI; also check if the linefeeds are set to DOS and consider switching them to Unix (depending on your server, of course).
When in doubt... use JSLint to get it out!
I just ran into a similar problem whilst copying this from JFiddle;
$('input[name=MeetAll]').change(function (e) {
$('#MeetMost').attr('checked', !$('#MeetAll').attr('checked'));
});
$('input[name=MeetMost]').change(function (e) {
$('#MeetAll').attr('checked', !$('#MeetMost').attr('checked'));
});
Jslint told me i had a random "." Charachter...
Things that make you go "hmmmmmm"
Double backslash also works ! Then you declare there really should be a / instead of some function or something.
<script>document.write('<script src="…"><//script>');</script>
It won't be exactly refering to the given problem, but I wanna share my mistake here, maybe some1 will make simmilar one and will also land with his/her problem here:
Ive got Unexpected token ILLEGAL
error because I named a function with a number as 1st char.
It was 3x3check()
. Changing it to check3x3()
solved my problem.
This error can also be caused by a javascript line like this one:
navi_elements.style.bottom = 20px;
Notice that the value is not a string.
You can use online Minify, it removes these invisible characters efficiently but also changes your code. So be careful.
참고URL : https://stackoverflow.com/questions/4404526/unexpected-token-illegal-in-webkit
'Program Tip' 카테고리의 다른 글
Java의 void 메소드에서 return 키워드는 무엇을합니까? (0) | 2020.11.29 |
---|---|
jQuery.validation에서 같지 않음 규칙을 추가하는 방법 (0) | 2020.11.29 |
WPF 연결 속성 데이터 바인딩 (0) | 2020.11.29 |
Chrome에서 CSS3 계산 (100 % -88px)이 작동하지 않음 (0) | 2020.11.29 |
''로 문장을 분할하고 주변 공백을 제거합니다. (0) | 2020.11.29 |