jQuery 无法在 IE 中运行
我在 WordPress 网站的 Internet Explorer 中运行 jQuery 脚本时遇到问题。在 Firefox 和 Chrome 上它运行顺利,但 IE 不想和我一起玩。
我认为这在 WordPress 的 jQuery 中可能会发生冲突,因为我的脚本在简单的“$variables”上运行良好。我正在使用“jQueryvariable”,就像他们在 http: //wordpress.org/support/topic/using-jquery-in-own-plugins#post-687280 但在 IE 中仍然无法正常工作。
任何人都可以告诉我如何在 WordPress 中正确包含我自己的 jQuery 文件?
非常感谢您的帮助。
function MoveItems() {
jQuery('.container>div:first').animate({
width: '0px'
}, 1000, function () {
var mine = jQuery(this);
mine.parent().append(mine);
jQuery(this).css({
width: '120px'
});
});
jQuery('#bands>h2:first').fadeTo(
4000, 0, function () {
var mine = jQuery(this);
mine.parent().append(mine);
jQuery(this).fadeTo(
1, 1);
});
};
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
});
});
});
i have a problem with running my jQuery scripts in Internet Explorer at my Wordpress sites. On Firefox and Chrome it is working smoothly, but IE does not want to play with me.
I think that this can be conflict in wordpress's jQuery because my script is working well on simple "$variables". I'am using "jQueryvariable" like they saying in http://wordpress.org/support/topic/using-jquery-in-own-plugins#post-687280 but in IE is still not working.
Anyone can tell me how to include my own jQuery files in wordpress properly?
Thank You very much for help.
function MoveItems() {
jQuery('.container>div:first').animate({
width: '0px'
}, 1000, function () {
var mine = jQuery(this);
mine.parent().append(mine);
jQuery(this).css({
width: '120px'
});
});
jQuery('#bands>h2:first').fadeTo(
4000, 0, function () {
var mine = jQuery(this);
mine.parent().append(mine);
jQuery(this).fadeTo(
1, 1);
});
};
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
});
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
好的,我有解决方案。在最新的 WordPress 版本中,jquery 和 ie8(有时是 Opera)存在已知错误。
有关错误的更多信息,请参见:https://wordpress .stackexchange.com/questions/10719/jquery-in-ie8-no-longer-works-after-3-1-upgrade
解决方案:
OK i have the solution. There is a know error with jquery and ie8 (sometimes opera) in latest wordpress releases.
more about error here: https://wordpress.stackexchange.com/questions/10719/jquery-in-ie8-no-longer-works-after-3-1-upgrade
SOLUTION:
尝试先添加此:
并查看是否显示警报...如果显示警报,那么我认为它不是 jquery 问题
Try to add this first :
and see whether alert is display or not...If alert is display then its not jquery issue i think
附上您认为可能与 WordPress 冲突的 Jquery 部分,
看看它是否有效。
Enclose the part of Jquery that you think, might be conflicting with wordpress into
see if it works.
IE 不喜欢您分配某些变量的方式。也有可能 IE 认为容器是一个全局变量。
看看这是否有帮助。 body 可以是容器的任何父容器。
这听起来很牵强,但我在 Ie 上看到过同样的错误,这是由于注册表问题破坏了 javascript 引擎而导致的。
如果代码不起作用,请查看是否可以在另一台运行 IE 的计算机上尝试。
我还注意到您的所有 javascript 文件都有 mime 类型错误。可能不是这个问题的原因,但还有其他需要注意的地方。
IE doesn't like the way your assigning some of the variables. It could also be that IE thinks container is a global variable.
See if this helps. body can be any parent container of container.
It sounds far fetched but I've seen the same error on Ie caused by registry problems corrupting the javascript engine.
If the code doesn't work see if you can try it on another computer running IE.
I also noticed you have mime type errors for all your javascript files. Might not be the cause of this problem but something else to take a look at.