gpt4 book ai didi

javascript - IE 7/8 中奇怪的 Javascript 怪癖

转载 作者:行者123 更新时间:2023-11-28 21:11:29 25 4
gpt4 key购买 nike

我的页面上有一个滑动轮播,当我在 IE 中访问我的页面时,它不起作用,而是应该在轮播中的图像以列表格式显示,就好像我的浏览器没有读取选择器的 javascript 一样应用效果。

到目前为止,这只发生在 IE7/8 中,当我在 firebug 中查看源代码时,就好像我的脚本标签在有机会看到 jQuery 之前就被浏览器关闭了。

如果我在 jQuery 之前添加 JS 警报,则会弹出警报,然后加载 jquery,这样我的轮播就可以工作了。

<script type="text/javascript">

//This works with an alert, without it the browser renders <script type="text/javascript" />
alert('test');

$(document).ready(function() {
$('#seasonaloffers').carousel({
start: 1
});
$('#newproducts').carousel({
start: 1
});
});
</script>

最佳答案

三件事:

  1. 验证您的 html - http://validator.w3.org/
  2. 检查您是否错误地重复了该 #id
  3. 使用 strict/html5 文档类型 - http://ejohn.org/blog/html5-doctype/

关于javascript - IE 7/8 中奇怪的 Javascript 怪癖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8507622/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com