0
我想避免litebox在Android或Apple設備的小視口上打開。如何避免在小視口上打開litebox?
這裏是我試過了,沒有成功:
$(document).ajaxComplete(function() { \t
$('.litebox').liteBox({
callbackBeforeOpen: function() {
console.log('open');
var windowsize = $(window).width();
// test the viewport size to see if it's smaller than 480px
if (windowsize < 1000) {
// cancel the lightbox and load the link url
console.log('close');
$(this).closeLitebox();
}
}
}); \t
\t \t
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://rawgit.com/joemottershaw/litebox/master/assets/js/litebox.js"></script>
<a href="https://www.youtube.com/watch?v=gOLY7bjCTTE" target="_blank" class="litebox">Video</a>
我的錯誤...
TypeError: $(...).closeLitebox is not a function
$(this).closeLitebox();