gpt4 book ai didi

JavaScript 导航在 IE8 中不起作用

转载 作者:行者123 更新时间:2023-11-28 09:20:14 26 4
gpt4 key购买 nike

我正在使用 everythingslider 和 colorbox 创建一个水平滑动页面,类似于电子书。我已经在 everythingslider 中实现了“nav(to)”函数来构建导航,它在 Firefox 和 Safari 中运行得非常好,但在 IE8 中却不行。令人沮丧的是, slider 部分仍然有效 - 它会向左和向右移动,它只是无法与导航一起直接跳转到“页面”(实际上是一个列表项)。我怀疑 IE8 拒绝了某些挑剔的语法,但我找不到它来拯救我的生命。

为了充分披露,该页面的代码最初是使用 in5 创建的,它将 InDesign 文档转换为 HTML。它有点草率,并没有完成我想要的一切,所以我已经手动编码了大约两周来调整它(并且花了两周的事实应该解释为什么我无法找出问题所在。如果还不清楚,我是个菜鸟)。

我到处寻找答案,包括 stackoverflow、github 和 csstricks。我找不到任何人来解决我的具体问题,并且为类似问题提供的答案要么是我已经做过的事情,要么是毫无乐趣地实现的事情。我修改了元标记以适应 IE8。我已经美化了 javascript 文件,这样我就可以准确地找到外部 .js 文件中定义导航的位置(我找到了它,但我还不是一个 javascript 程序员,无法完全理解我正在查看的内容)。

所以这是代码:

<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<title>BestBrands2013</title>
<meta http-equiv="X-UA-Compatible" content="IE=8">

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="assets/js/jquery.min.js"><\/script>')</script>
<script type="text/javascript" src="assets/js/jquery.touchSwipe.min.js"></script>
<script type="text/javascript" src="assets/js/jquery.anythingslider.min.js"></script>
<script type="text/javascript" src="assets/js/jquery.colorbox-min.js"></script>
<link rel="stylesheet" href="assets/css/theme-minimalist-square.css">
<link rel="stylesheet" href="assets/css/pages.css">


<script type="text/javascript" >
var touchEnabled = 'ontouchstart' in document.documentElement;
var useSwipe = 1;
var pageMode = 'h';
var nav;

$(function(){

if($.colorbox) {
$('.lightbox').colorbox({iframe:true, width:"80%", height:"80%"});
$('.thumb').colorbox({maxWidth:"85%", maxHeight:"85%"});
}
$('img').bind('dragstart', function(event) { event.preventDefault(); });
$('.pageItem').each(function(){
if($(this).is('[onclick]')){
if(touchEnabled) {
//this.setAttribute('touchstart', this.getAttribute('onclick'));
//this.removeAttribute('onclick');
} else this.style.cursor = 'pointer';
}
});
if($.hasOwnProperty('scrollTo')){
nav = { numPages:$('.pages .page').length,
back:function(ref){var targ=$(ref).parent('.page').prev()[0]; if(targ!=undefined); $.scrollTo(targ, 500);},
next:function(ref){var targ=$(ref).parent('.page').next()[0]; if(targ!=undefined); $.scrollTo(targ, 500);},
first:function(){$.scrollTo($('.page')[0], 500)},
last:function(){$.scrollTo($('.page')[nav.numPages-1], 500)},
to:function(n){$.scrollTo($('.page')[n-1], 500)} };
}
var playvid = function(slider) {
var vid = slider.$currentPage.find('video');
if (vid.length) {
// autoplay
vid[0].play();
}
};
var sliderSettings = {
mode: pageMode,
theme: 'minimalist-square',
buildArrows: (!touchEnabled && 1),
buildNavigation: false,
buildStartStop: false,
hashTags: false,
infiniteSlides: false,
stopAtEnd: true,
onInitialized: function(e, slider) {
playvid(slider);
nav = {
numPages:slider.pages,
current:slider.currentPage,
next:function(){slider.goForward();},
back:function(){slider.goBack();},
first:function(){this.to(1);},
last:function(){this.to(this.numPages)},
to:function(n){slider.gotoPage(n);}
};
if(useSwipe) {
var container = $('#container');
var vertMode = (pageMode.substr(0,1) == "v");
container.swipe({
swipe:function(event, direction, distance, duration, fingerCount) {
switch(direction) {
case "left":
if(!vertMode) nav.next();
break;
case "right":
if(!vertMode) nav.back();
break;
case "up":
if(vertMode) nav.next();
break;
case "down":
if(vertMode) nav.back();
break;
}
}
});
}
},

}

$('#slider').anythingSlider(sliderSettings);
});
</script>

</head>

<body>
<div id="container">
<ul class="pages" id="slider">

<li class="page">
<img class="pageItem" src="assets/images/item_16.png" alt="page item"/>
<a href = "javascript:void(0)" onclick = "document.getElementById('popclinique').style.display='block';document.getElementById('fade').style.display='block'">
<img class="pageItem" src="assets/images/item_17.png" style="left:165px; top:116px; " alt="page item"/>
</a>
<a href="https://shop.aafes.com/shop/default.aspx?loc=department.aspx%7Edept_id%3D8520&cm_sp=ebook-_-30513-_-bb_p2_clinique_sun" target="_blank"><img class="pageItem" src="assets/images/item_18.png" style="left:85px; top:381px; " alt="Clinique Sun"/></a>
<a href = "javascript:void(0)" onclick = "document.getElementById('popmilstar').style.display='block';document.getElementById('fade').style.display='block'">
<img class="pageItem" src="assets/images/item_19.png" style="left:38px; top:567px; " alt="page item"/>
</a>
<a href="https://shop.aafes.com/shop/default.aspx?loc=department.aspx%7Edept_id%3D8517&cm_sp=ebook-_-30513-_-bb_p2_clinique_fragrance" target="_blank"><img class="pageItem" src="assets/images/item_20.png" style="left:271px; top:210px; " alt="Clinique Fragrance"/></a>
<a href="https://shop.aafes.com/shop/default.aspx?loc=department.aspx%7Edept_id%3D8523&cm_sp=ebook-_-30513-_-bb_p2_clinique_mens" target="_blank"><img class="pageItem" src="assets/images/item_21.png" style="left:436px; top:207px; " alt="Clinique Mens"/></a>
<a href="https://shop.aafes.com/shop/default.aspx?loc=department.aspx%7Edept_id%3D8501&cm_sp=ebook-_-30513-_-bb_p2_clinique_3step" target="_blank"><img class="pageItem" src="assets/images/item_22.png" style="left:591px; top:318px; " alt="Clinique 3 Step"/></a>
<a href="https://shop.aafes.com/shop/default.aspx?loc=department.aspx%7Edept_id%3D8512&cm_sp=ebook-_-30513-_-bb_p2_clinique_makeup" target="_blank"><img class="pageItem" src="assets/images/item_23.png" style="left:864px; top:350px; " alt="Clinique Makeup"/></a>
<a href="https://shop.aafes.com/shop/default.aspx?loc=department.aspx%7Edept_id%3D8505&cm_sp=ebook-_-30513-_-bb_p2_clinique_skincare" target="_blank"><img class="pageItem" src="assets/images/item_24.png" style="left:696px; top:47px; " alt="Clinique Skin Care"/></a>
<button class="pageItem" style="left:217px; top:641px; " alt="clinique 11" id="item26" onclick="nav.to(2);">&nbsp;</button>
<button class="pageItem" style="left:271px; top:641px; " alt="nikebutton 11" id="item27" onclick="nav.to(3);">&nbsp;</button>
<button class="pageItem" style="left:325px; top:641px; " alt="underarmourbuttpn 11" id="item28" onclick="nav.to(4);">&nbsp;</button>
<button class="pageItem" style="left:379px; top:641px; " alt="coachbutton 11" id="item29" onclick="nav.to(5);">&nbsp;</button>
<button class="pageItem" style="left:433px; top:641px; " alt="fossilbutton 11" id="item30" onclick="nav.to(6);">&nbsp;</button>
<button class="pageItem" style="left:487px; top:641px; " alt="keurigbutton 11" id="item31" onclick="nav.to(7);">&nbsp;</button>
<button class="pageItem" style="left:541px; top:641px; " alt="dellbutton 11" id="item32" onclick="nav.to(8);">&nbsp;</button>
<button class="pageItem" style="left:595px; top:641px; " alt="applebutton 11" id="item33" onclick="nav.to(9);">&nbsp;</button>
<button class="pageItem" style="left:649px; top:641px; " alt="dysonbutton 11" id="item34" onclick="nav.to(10);">&nbsp;</button>
<button class="pageItem" style="left:703px; top:641px; " alt="samsungbutton 11" id="item35" onclick="nav.to(11);">&nbsp;</button>
<button class="pageItem" style="left:757px; top:641px; " alt="knmorebutton 11" id="item36" onclick="nav.to(12);">&nbsp;</button>
<img class="pageItem" src="assets/images/item_25.png" style="left:16px; top:12px; " alt="page item"/>
</li>
</body>

我已经缩写了很多 - 整个事情是巨大的 - 但这是整个头部部分。我只包含一个“页面”(实际上是一个列表项)。相关位是 onclick="nav.to(n);"位于末尾的按钮,以及靠近头部末尾的脚本的 slidersettings block 中的导航定义。

我知道每个人可能都有实际的编程问题需要回答,而我微弱的编程工作在您的优先事项列表中排在后面,但我正在拼命地尽可能快地学习这些东西,并且将非常感谢任何人可以提供的帮助报价。

最佳答案

在脚本 block 的末尾有一个额外的逗号。 IE8 因这些问题而臭名昭著。

                }
}
});
}
}, <-- here

}

关于JavaScript 导航在 IE8 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15093219/

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