问题
I need to play videos in fancybox.
As per this solution
I started working
My a href tag looks like
<a class="fancybox" href="/uploads/ckeditor/attachments/55/myvideo.mp4">
<img class="check" height="120" weight="160" src="/uploads/ckeditor/attachments/55/myvideo.jpg" alt="Myvideo">
</a>
and my jquery
$(document).ready(function () {
$("a.fancybox").fancybox({
fitToView: false,
content: '<span></span>',
scrolling: 'no',
afterLoad: function (){
this.content = "<embed src='/jwplayer.swf?file=" + this.href + "&autostart=true&wmode=opaque' type='application/mp4' width='140' height='180'></embed>";
}
});
});
While ckick on that image it fancybox responds with nothing. No error in console and browser
my fancybox content doesn't have apart from the following line
<div id="fancybox-content" style="border-width: 10px; width: 0px; height: auto;">
please help me. Thanks a lot in advance.
回答1:
This is worked for me finally.
$(document).ready(function() {
$(".fancybox").fancybox({
type: "iframe",
width : 380, // or whatever
height: 280
}).trigger("click");
});
来源:https://stackoverflow.com/questions/23191946/fancybox-video-highlight-with-nothing-in-rails