Pat*_*rlt 61 javascript safari jquery google-chrome
// 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;
});
});
Run Code Online (Sandbox Code Playgroud)
我得到一个未捕获的SyntaxError:上面提到的行上的意外的令牌ILLEGAL.它仅在Google Chrome和Safari中出现.它适用于Firefox,相同的代码适用于此JSBin(http://jsbin.com/uceqi/18)
到底是怎么回事?
Stackoverflow上有很多关于这个问题的引用,但它们似乎都不适用于这种情况.
如果它有助于JSLint也在该行字符2"第22行的问题2:意外的''中引发错误和错误."
use*_*716 136
删除该区域周围的所有不可见字符(空白),然后再试一次.
复制/粘贴代码时,我在Safari中看到了这个错误.您可以选择一些无效(不幸的是不可见)字符.
从jsFiddle复制时,曾经发生过很多事.
Hen*_*k N 14
它不适用于此特定代码示例,但作为Google食品,因为我收到了相同的错误消息:
<script>document.write('<script src="…"></script>');</script>
Run Code Online (Sandbox Code Playgroud)
会给出这个错误但是
<script>document.write('<script src="…"><'+'/script>');</script>
Run Code Online (Sandbox Code Playgroud)
将不会.
这里有进一步的解释:为什么在用document.write()编写<script>标签时将其拆分?
当脚本文件包含容器一些特殊字符时以及当我在本地moode(直接从本地磁盘)运行时,我得到了同样的错误.我的情况解决方案是明确告诉编码:
<script src="my.js" charset="UTF-8"></script>
Run Code Online (Sandbox Code Playgroud)
小智 6
对于运行Vagrant的任何人都要注意:这可能是由共享文件夹的错误引起的.为Vagrantfile中的共享文件夹指定NFS以避免发生这种情况.
简单地添加type: "nfs"到最后将完成这个技巧,如下所示:
config.vm.synced_folder ".", "/vagrant", type: "nfs"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
111134 次 |
| 最近记录: |