首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未捕获的SyntaxError:意外的标识符- Wordpress迁移

未捕获的SyntaxError:意外的标识符- Wordpress迁移
EN

Stack Overflow用户
提问于 2015-04-20 23:26:25
回答 1查看 958关注 0票数 0

我正在将一个本地的Wordpress网站迁移到它的live域中。当在本地托管(MAMP)时,一切都运行得很好,但当上传到我的域名时,它会被加载程序卡住,并在Chrome的控制台中显示以下错误:

未捕获的SyntaxError:意外的标识符

代码语言:javascript
复制
/* LOADER */
jQuery(window).load(function() {
    jQuery(".status").fadeOut();
    jQuery(".preloader").delay(1000).fadeOut("slow");
});

/** BACKGROUND SLIDER ***/
jQuery(document).ready(function(){
    if ( jQuery('.fadein-slider .slide-item').length > 1 ) {
        jQuery('.fadein-slider .slide-item:gt(0)').hide();
        setInterval(function(){
            jQuery('.fadein-slider :first-child').fadeOut(2000).next('.slide-item').fadeIn(2000).end().appendTo('.fadein-slider');
        }, 10000);
    }
});

/*** DROPDOWN FOR MOBILE MENU */
var callback_mobile_dropdown = function () {
    if ( jQuery(window).width() < 767 ){

        jQuery('#site-navigation li').each(function(){

            if ( jQuery(this).find('ul').length > 0 ){
                jQuery(this).addClass('has_children');
                jQuery(this).find('a').first().after('<p class="dropdownmenu"></p>');
            }

        });

    }

    jQuery('.dropdownmenu').click(function(){
        if( jQuery(this).parent('li').hasClass('this-open') ){
            jQuery(this).parent('li').removeClass('this-open');
        }else{
            jQuery(this).parent('li').addClass('this-open');
        }
    });
};

jQuery(document).ready(callback_mobile_dropdown);
jQuery(window).resize(callback_mobile_dropdown);


/* show/hide reCaptcha */
jQuery(document).ready(function() {

  var thisOpen = false;
  jQuery('.contact-form .form-control').each(function(){
    if ( (typeof jQuery(this).val() != 'undefined') && (jQuery(this).val().length > 0) ){
      thisOpen = true;
      jQuery('.g-recaptcha').css('display','block').delay(1000).css('opacity','1');
      return false;
    }
  });
  if ( thisOpen == false && (typeof jQuery('.contact-form textarea').val() != 'undefined') && (jQuery('.contact-form textarea').val().length > 0) ) {
    thisOpen = true;
    jQuery('.g-recaptcha').css('display','block').delay(1000).css('opacity','1');
  }
  jQuery('.contact-form input, .contact-form textarea').focus(function(){
    if ( !jQuery('.g-recaptcha').hasClass('recaptcha-display') ) {
        jQuery('.g-recaptcha').css('display','block').delay(1000).css('opacity','1');
    }
  });

});

/* Bootstrap Fix */
if (navigator.userAgent.match(/IEMobile\/10\.0/)) {

    var msViewportStyle = document.createElement('style')

    msViewportStyle.appendChild(

        document.createTextNode(

            '@-ms-viewport{width:auto!important}'

        )

    )

    document.querySelector('head').appendChild(msViewportStyle);

}

jQuery(document).ready(function() {

    /*** SMOOTH SCROLL TO FRONPAGE SECTIONS */  
    /* when click on menu item that correspons to a section scroll to that section */
    jQuery('.main-nav-list a[href*=#]:not([href=#])').click(function() {

        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {

            var target = jQuery(this.hash);
            target = target.length ? target : jQuery('[name=' + this.hash.slice(1) +']');
            if (target.length) {
                jQuery('html,body').animate({
                    scrollTop: target.offset().top
                }, 1200);
                return false;
            }
        }

    });

    /** BACKGROUND IMAGE ONLY FOR FRONTPAGE **/
    jQuery('body:not(.home)').removeClass('custom-background');

    /* PARALLAX */
    var jQuerywindow = jQuery(window);

    jQuery('div[data-type="background"], header[data-type="background"], section[data-type="background"]').each(function(){

        var jQuerybgobj = jQuery(this);

        jQuery(window).scroll(function() {

            var yPos = -(jQuerywindow.scrollTop() / jQuerybgobj.data('speed'));

            var coords = '50% '+ yPos + 'px';

            jQuerybgobj.css({ 

                backgroundPosition: coords 

            });

        });

    });

});

jQuery(window).load(function() {

    /* FOOTER */
    /* vp_h will hold the height of the browser window */
    var vp_h = jQuery(window).height();

    /* b_g will hold the height of the html body */
    var b_g = jQuery('body').height();

    /* If the body height is lower than window */
    if(b_g < vp_h) {

        jQuery('footer').css("position","absolute");
        jQuery('footer').css("bottom","0px");
        jQuery('footer').css("width","100%");

    }

    /* SUBSCRIBE  */
    jQuery("form :input").each(function(index, elem) {

        var eId = jQuery(elem).attr("class");

        if( (eId == "sib-email-area") || (eId == "sib-NAME-area") ) {

            var label = null;
            if (eId && (label = jQuery(elem).parents("form").find("label."+eId)).length == 1) {
                jQuery(elem).attr("placeholder", jQuery(label).html());
                jQuery(label).remove();
            }
        }
    });
}); 


/* TOP NAVIGATION MENU SELECTED ITEMS */
jQuery(window).scroll(function(){

    var zerif_scrollTop = jQuery(window).scrollTop();
    var zerif_windowHeight = jQuery(window).height();

    jQuery("section").each( function() {

        var zerif_offset = jQuery(this).offset();

        if (zerif_scrollTop <= zerif_offset.top && (jQuery(this).height() + zerif_offset.top) < (zerif_scrollTop + zerif_windowHeight) ) {

            jQuery('ul.nav > li a').each( function() {
                jQuery(this).removeClass('nav-active');
            });

            var zerif_current_id_visible = jQuery(this).attr('id');

            jQuery('ul.nav > li a').each( function() {
                if( jQuery(this).attr('href').indexOf(zerif_current_id_visible) >= 0 ) {
                    jQuery('ul.nav > li a').each( function() {
                        jQuery(this).removeClass('nav-active');
                    });
                    jQuery(this).addClass('nav-active');
                }

            });
        }

    });

});


jQuery(document).ready(function(){
    setminHeightHeader();
});

jQuery(window).resize(function() {
    setminHeightHeader();
    cloneMenu();
});

function setminHeightHeader() 
{
    jQuery('#main-nav').css('min-height','75px');
    jQuery('.header').css('min-height','75px');
    var minHeight = parseInt( jQuery('#main-nav').height() );
    jQuery('#main-nav').css('min-height',minHeight);
    jQuery('.header').css('min-height',minHeight);
}

function cloneMenu()
{
    jQuery( '.collapse.in').removeClass('in');
    jQuery( '.navbar-toggle.collapsed').removeClass('collapsed');
}

我对javascript的编辑不是很熟悉,所以如果有人看到任何明显的错误,我将非常感谢你的帮助!

EN

回答 1

Stack Overflow用户

发布于 2015-04-21 01:35:20

您的站点似乎没有加载jquery。检查Jquery js是否正确服务于客户端。我自己也浪费了很多时间调试同样的错误,结果服务器被配置为不直接向客户端提供文件,除非是从servlet提供的。可能是一个类似的case.Since,浏览器找不到Jquery标识符,这很可能是原因。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29752053

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档