jQuery在IE中不起作用

jQuery在IE中不起作用,jquery,wordpress,Jquery,Wordpress,我在Wordpress站点的Internet Explorer中运行jQuery脚本时遇到问题。在Firefox和Chrome上,它运行平稳,但IE不想和我玩 我认为wordpress的jQuery中可能存在冲突,因为我的脚本在简单的“$variables”上运行良好。我正在使用“jQueryvariable”,就像他们在中说的那样,但在IE中仍然不起作用 谁能告诉我如何在wordpress中正确地包含我自己的jQuery文件 非常感谢你的帮助 首先尝试添加以下内容: jQuery(docum

我在Wordpress站点的Internet Explorer中运行jQuery脚本时遇到问题。在Firefox和Chrome上,它运行平稳,但IE不想和我玩

我认为wordpress的jQuery中可能存在冲突,因为我的脚本在简单的“$variables”上运行良好。我正在使用“jQueryvariable”,就像他们在中说的那样,但在IE中仍然不起作用

谁能告诉我如何在wordpress中正确地包含我自己的jQuery文件

非常感谢你的帮助



首先尝试添加以下内容:

jQuery(document).ready(function($) { // When the document (page) has finished loading.

alert("jQuery is working!"); // Shows a window displaying "jQuery is working!"

}); 

并查看警报是否显示…如果警报显示,则其不是jquery问题,我认为

将jquery中您认为可能与wordpress冲突的部分括起来

        jQuery.noConflict();
        (function($){

           // type your jquery here 

         })(jQuery) ;

看看它是否有效。

IE不喜欢您分配某些变量的方式。也可能是IE认为容器是一个全局变量

看看这是否有帮助。主体可以是容器的任何父容器

function MoveItems() {
    jQuery('body').append('.container>div:first').animate({
        width: '0px'
    }, 1000, function () {
        var mine = jQuery(this);
        mine.parent().append(mine);
        jQuery(this).css({
            width: '120px'
        });
    });
    jQuery('body').append('#bands>h2:first').fadeTo(
    4000, 0, function () {
        var mine = jQuery(this);
        mine.parent().append(mine);
        jQuery(this).fadeTo(
        1, 1);
    });
}  //removed this semi colon based on error from jslint.

jQuery(document).ready(function () {
    var timer = setInterval(MoveItems, 1000);
    jQuery('#sponsors').hover(function () {
        clearInterval(timer);
    }, function () {
        timer = setInterval(MoveItems, 1000);
    });

    jQuery('.sponsor').mouseover(function () {
        jQuery('img', this).animate({
            width: "200px",
            height: "200px",
            left: "-40px",
            top: "-40px"
        }, {
            queue: false,
            duration: 500
        });
    });

    jQuery('.sponsor').mouseleave(function () {
        jQuery('img', this).animate({
            width: "120px",
            height: "120px",
            left: "0px",
            top: "0px"
        }, {
            queue: false,
            duration: 500
        });
    });

}); 
这听起来有些牵强,但我在Ie上看到了同样的错误,这是由于注册表问题损坏javascript引擎造成的

如果代码不起作用,看看你是否可以在另一台运行IE的计算机上试用

我还注意到所有javascript文件都有mime类型错误。可能不是导致此问题的原因,但还有其他原因需要注意

Resource interpreted as Script but transferred with MIME type application/octet-stream.
wp-scriptaculous.js:-1Resource interpreted as Script but transferred with MIME type application/octet-stream.
prototype.js:-1Resource interpreted as Script but transferred with MIME type application/octet-stream.
effects.js:-1Resource interpreted as Script but transferred with MIME type application/octet-stream.
lightbox.js:-1Resource interpreted as Script but transferred with MIME type application/octet-stream.
jquery.js:-1Resource interpreted as Script but transferred with MIME type application/octet-stream.
jquery.cycle.all.min.js:-1Resource interpreted as Script but transferred with MIME type application/octet-stream.
ngg.slideshow.min.js:-1Resource interpreted as Script but transferred with MIME type application/octet-stream.
webtoolkit.sprintf.js:-1Resource interpreted as Script but transferred with MIME type application/octet-stream.
fergcorp_countdownTimer_java.js:-1Resource interpreted as Script but transferred with MIME type application/octet-stream.
blink2_backup.js:-1Resource interpreted as Script but transferred with MIME type application/octet-stream.

好的,我有解决办法。在最新的wordpress发布中,jquery和ie8(有时是opera)存在已知错误

有关错误的详细信息,请参见此处:

解决方案:

//Making jQuery Google API
function modify_jquery() {
    if (!is_admin()) {
        // comment out the next two lines to load the local copy of jQuery
        wp_deregister_script('jquery');
        wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js', false, '1.6.1');
        wp_enqueue_script('jquery');
    }
}
add_action('init', 'modify_jquery');

“jQuery正在工作!”这就是我的脚本的问题?这是关于IE中的选择器的?那么为什么这在firefox和chrome中起作用呢?我已经在主要问题中添加了jquery代码,但我在IE中打开了它,它正在工作…我没有看到任何问题…页面底部的旋转木马中有一些照片,应该会有一些动作。。我做了一些调试,我的MoveItems函数有问题。可能与子选择器jQuery('.container>div:first').animate(…)一致,其他脚本也存在一些错误。这是IE给出的错误:如你所见,我已经粘贴了你的代码,但它仍然没有在我拥有的每台计算机上移动。;/我几乎可以肯定这是关于IE中CSS中的子选择器的,它不起作用,所以这在JS中应该不会有什么不同。但我不知道如何选择其他方式的元素/我是根据他的想法想出这个主意的。这可能有助于你弄清真相。
//Making jQuery Google API
function modify_jquery() {
    if (!is_admin()) {
        // comment out the next two lines to load the local copy of jQuery
        wp_deregister_script('jquery');
        wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js', false, '1.6.1');
        wp_enqueue_script('jquery');
    }
}
add_action('init', 'modify_jquery');