下面的代码嵌入到我的html文件中,但它们似乎相互干扰(第一个脚本用于触摸链接,第二个脚本是平滑滚动功能)。
如果我要删除第一个,我的平滑滚动就能正常工作。但这两者结合在一起,我的平滑滚动就搞砸了。我认为解决方案可能在-window.open(link,'_self')-这一行。我对Javascript的了解很少,所以任何帮助都会非常感谢!
来自比利时的问候。
<script>
$(function () {
$('a').on('click touchend', function() {
var link = $(this).attr('href');
window.open(link,'_self');
return false; // prevent anchor click
});
});
</script>
<script type="text/javascript">
$( document ).ready(function( $ ) {
$( '#Slider1' ).sliderPro({
width: 1000,
height: 520,
arrows: true,
buttons: true,
waitForLayers: true,
thumbnailWidth: 200,
thumbnailHeight: 100,
thumbnailPointer: true,
autoplay: false,
autoScaleLayers: false,
breakpoints: {
500: {
thumbnailWidth: 120,
thumbnailHeight: 50
}
}
});
});
</script>发布于 2015-06-21 04:35:02
按照这个顺序组合这两个脚本,试试这个:
<script type="text/javascript">
$( document ).ready(function( $ ) {
$( '#Slider1' ).sliderPro({
width: 1000,
height: 520,
arrows: true,
buttons: true,
waitForLayers: true,
thumbnailWidth: 200,
thumbnailHeight: 100,
thumbnailPointer: true,
autoplay: false,
autoScaleLayers: false,
breakpoints: {
500: {
thumbnailWidth: 120,
thumbnailHeight: 50
}
}
});
$('a').on('click touchend', function() {
var link = $(this).attr('href');
window.open(link,'_self');
return false; // prevent anchor click
});
});
</script>https://stackoverflow.com/questions/30958210
复制相似问题