为了账号安全,请及时绑定邮箱和手机立即绑定

Webkit中出现意外的令牌非法

Webkit中出现意外的令牌非法

// if the box is outside the window, move it to the endfunction 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 rowfunction 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 windowfunction shiftLeft() {    $('.box').animate({'left' : "-=100px"}, 5000, 'linear', checkEdge());}// returns the new location for the box that exited the windowfunction getNewPosition() {    return $('.box:last').position().left + $('.box:last').outerWidth();}我在上面提到的行上收到了Uncaught SyntaxError:意外的令牌ILLEGAL。它仅在Google Chrome和Safari中发生。它可以在Firefox中运行,并且相同的代码也可以在此JSBin(http://jsbin.com/uceqi/18)上运行到底是怎么回事?在Stackoverflow上有很多关于此问题的参考,但是似乎没有一个适用于这种情况。如果有帮助,JSLint还会在该行字符2“第22行字符2:问题'意外'”上抛出错误。
查看完整描述

3 回答

?
收到一只叮咚

TA贡献1821条经验 获得超4个赞

删除该区域周围的所有不可见字符(空格),然后再试一次。


复制/粘贴代码时,我已经在Safari中看到该错误。您可以选择一些无效(不幸的是不可见)字符。


从jsFiddle复制时,经常发生在我身上。


查看完整回答
反对 回复 2019-11-18
  • 3 回答
  • 0 关注
  • 532 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信