我在使这个 JQuery 在 Internet Explorer 中工作时遇到了一些麻烦,它在 FF、WebKit 等中工作得很好,向上滑动、弹起并落回原位,但在 Internet Explorer 中它什么也不做,按钮不起作用并且内容在页面加载时永远不会向上滑动。这真的很奇怪,我的网站的早期设计中有一个元素淡出,它在 IE 中不起作用,但在其他所有东西中都起作用......
<script>
$(document).ready(function(){
$('#homecontent').delay("750").animate({ marginTop: "-15px" }, 1500).animate({ marginTop: "5px" }, 500);
})
</script>
<script>
$("#shop").click(function(){
$('#homecontent').animate({ marginTop: "1500px" }, 1500).delay("1500", function(){
window.location.href = "http://www.jamiedurham.co.uk/shop/","shop"
});
})
$("#blog").click(function(){
$('#homecontent').animate({ marginTop: "1500px" }, 1500).delay("1500", function(){
window.location.href = "http://www.jamiedurham.co.uk/blog/","blog"
});
})
</script>
<div id="homecontent" style="width:1000px; margin-left:20px; margin-right:20px; position:absolute; margin-top:1500px; line-height:19px;"></div>
<table style="margin-top:70px;">
<tr style="height:50px; width:738px;">
<td style="width:242px;"><a href="http://www.jamiedurham.co.uk/" ><img src="http://www.jamiedurham.co.uk/pics/homehover.gif" alt="home" name="home" id="home"></a></td>
<td style="width:242px;"><a href="http://www.jamiedurham.co.uk/shop" id="shop" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('shop','','http://www.jamiedurham.co.uk/pics/partnershover.gif',1)"><img src="http://www.jamiedurham.co.uk/pics/shop.gif" alt="shop" name="shop" id="shop"></a></td>
<td style="width:242px;"><a id="blog" href="http://www.jamiedurham.co.uk/blog" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('blog','','http://www.jamiedurham.co.uk/pics/bloghover.gif',1)"><img src="http://www.jamiedurham.co.uk/pics/blog.gif" alt="blog" name="blog" id="blog"></a></td>
</tr>
</table>
http://jsfiddle.net/koolvin/MXwXA/5/ http://jsfiddle.net/koolvin/MXwXA/5/这已经在所有 IE 版本中进行了测试,它适用于 IE6+
我做了三件事:
- 我让它看起来不错
- 我以以下方式结束声明
;
- 我添加了 e.preventDefault() 以确保您的 javascript 按预期工作。
相当于:
$(document).ready(function() {
$('#homecontent').delay("750").animate({
marginTop: "-15px"
}, 1500).animate({
marginTop: "5px"
}, 500);
});
$("#shop").click(function(e) {
e.preventDefault();
$('#homecontent').animate({
marginTop: "1500px"
}, 1500).delay("1500", function() {
window.location.href = "http://www.jamiedurham.co.uk/shop/", "shop"
});
});
$("#blog").click(function(e) {
e.preventDefault();
$('#homecontent').animate({
marginTop: "1500px"
}, 1500).delay("1500", function() {
window.location.href = "http://www.jamiedurham.co.uk/blog/", "blog"
});
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)