相关疑难解决方法(0)

Chrome Uncaught语法错误:意外令牌ILLEGAL

可能重复:
SyntaxError:意外的标记ILLEGAL

Chrome尝试在页面上加载脚本文件时收到主题错误.它说这是在javascript文件的最后一行.我似乎无法找到任何错误.firefox中没有错误,脚本按预期工作.只需使用表单验证

// JavaScript Document
$(function() {
  $('#wm-form').submit(function() {
    var errors = false;
    var errorMsg = "";
    $('.required').each(function() {
      if(!validField($(this))) {
        errorMsg += $(this).attr('name').capitalize() + " cannot be blank\n";
        errors = true;
      }
    });
    var emailAddress = $('#email');
    if(isValid(emailAddress) && !(/^(([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+([;.](([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+)*$/.test(emailAddress.val()))) {
      errorMsg += "Not a valid email address. Please enter in a correctly formatted email address";
      errors = true;
    }
    if(errors) {
      alert(errorMsg);
      return false;
    }
  });

  $('.form-focus').click(function() {
    $(document).scrollTop(0);
    $('#first_name').focus();
    return false;
  });
});

function validField(element) { …
Run Code Online (Sandbox Code Playgroud)

javascript jquery google-chrome

137
推荐指数
3
解决办法
44万
查看次数

webkit中的意外标记ILLEGAL

// 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 …
Run Code Online (Sandbox Code Playgroud)

javascript safari jquery google-chrome

61
推荐指数
4
解决办法
11万
查看次数

标签 统计

google-chrome ×2

javascript ×2

jquery ×2

safari ×1