javascript - Javascript 不适用于 ie 浏览器和 ff
问题描述
我有一个 javascript 将新闻和事件的高度重定向到最高,以便它们都具有相同的高度大小,不知何故它在 mozilla 和 ie 中不起作用。
但是,使用 chrome 时,它可以完全发挥作用,使它们的大小都相同。其他浏览器都没有在控制台中显示任何错误,所以我很难调试它
这是我索引页面的唯一部分,包括我使用的 div 和 js 中的脚本,我使用 laravel 作为框架顺便说一句:
<div class="col-md-8 news homepage s2">
<div class="swiper-container">
<div class="swiper-wrapper">
@foreach($events as $n)
<div class="swiper-slide remove_p">
<h4>{!! nl2br($n['titulo_'.$lang]) !!}</h4>
{!! nl2br($n['desc_'.$lang]) !!}
<a href="{{ ROUTE('page', ['cat' => 'eventos', 'id' => $n->id]) }}" class="link more_btn">{{ $geral['SAIBA_MAIS']->value }}</a>
</div>
@endforeach
</div>
</div>
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
</div>
</div>
</div>
@section('scripts')
@parent
<script type="text/javascript">
var mySwiper = new Swiper('.homepage.s1 .swiper-container', {
speed: 400,
spaceBetween: 30,
slidesPerView: 3,
navigation: {
nextEl: '.homepage.s1 .swiper-button-next',
prevEl: '.homepage.s1 .swiper-button-prev',
},
breakpoints: {
480: {
slidesPerView: 1,
spaceBetween: 100
}
}
});
var mySwiper = new Swiper('.homepage.s2 .swiper-container', {
speed: 400,
spaceBetween: 30,
slidesPerView: 3,
navigation: {
nextEl: '.homepage.s2 .swiper-button-next',
prevEl: '.homepage.s2 .swiper-button-prev',
},
breakpoints: {
480: {
slidesPerView: 1,
spaceBetween: 100
}
}
});
</script>
<script>
setTimeout(resizeSwiper, 500)
setTimeout(resizeSwiper, 1000)
setTimeout(resizeSwiper, 2000)
setTimeout(resizeSwiper, 3000)
function resizeSwiper() {
$('.swiper-container').each(function() {
var $this = $(this)
var height = 0
$this.find('.swiper-slide').each(function() {
var s_title_h = $(this).find('h4').height()
var s_p_h = $(this).find('p').eq(0).height()
if(height < (s_title_h + s_p_h)) {
height = (s_title_h + s_p_h)
}
})
$this.css({
'height': height + 50
})
$(this).parent().parent().find('.col-md-4.line_block').css({
'height': height + 50
})
$(this).parent().parent().find('.col-md-4.img_eventos').css({
'height': height + 50
})
})
/*$('.img_eventos').css({
'height': $('.swiper-container').eq(1).height() + 0
})*/
}
</script>
@endsection
滑块也是如此,它没有在两个浏览器中显示
解决方案
推荐阅读
- java - Swagger 2 annotations - 地图的有意义的模式示例
- excel - VBA 在另一列中的列中搜索值,如果未找到,则显示哪个,如果找到,则将偏移值复制到偏移量输入
- java - 如何使用 Spring Batch 读取 CSV,对其进行处理并将其写入为 CSV,一行可以产生多行?
- javascript - Nuxt.js:如何使用特定路径值启动服务器?
- sql-server - 在 SQL Server 中,如果我对多个字段有 UNIQUE 约束,是否需要在其中一个字段上建立索引?
- gnuplot - Gnuplot:用循环绘制编号文件
- python - 如何将列添加到具有基于列值的范围填充的行的熊猫数据框中
- scala - 是否可以在 Iterable 上进行模式匹配
- javascript - 使用 laravel 从为 js 生成的动态 html 中获取值
- node.js - 在本地提供 Firebase 托管站点时获得“权限被拒绝”