I am trying to mirror the functionality of the video player on this page, when you click View a Product Demonstration. It pops up with a new window (not a new tab) where scrolling is disabled and a size is defined. It is important that my pop-up has this too. A dialog box won't work.
The video I'm using is a YouTube video; I can make the video pop-up by itself from clicking a link on a page. However, I need to also be able to display other content in the pop-up (images + text) window.
I am new to jQuery so I don't know the best approach to achieve this. My first thought was that I could put everything in a hidden div, and then make that content display in a new window when an element is clicked, and apply css with the jQuery when clicked to make it display properly.
After researching on SO, I found this, which sort of works. The problem is that it opens in a new tab, not a new window, and the CSS is lost in the new tab (which I can fix with inline styles, not ideal but I can live with it). I could use this if I could make it a new window instead of tab. Here is my code in a fiddle and here it is below:
<script type="text/javascript">
function printClick() {
var w = window.open();
var html = $("#video-container").html();
$(w.document.body).html(html);
}
$(function() {
$("a#video-link").click(printClick);
});
</script>
and then:
<div id="product-description">
<a href="#" id="video-link">
<img src="cookware-product-demonstration-video.png" alt="View Product Demonstration Video" width="355" height="55" style="padding: 0px 0px 10px 0px;" border="0" />
</a>
</div>
<div id="video-container" style="display: none;>
<div id="video" style="width: 600px; position: relative; margin: 0px auto;">
<div id="video-header">
<img src="logo.gif" height="30" width="120" alt="Company Logo" style="float: left;"/>
<p style="float: right">Product Demonstration Video</p>
</div>
<iframe width="600" height="338" src="http://www.youtube.com/embed/yeuCLMppZzc?rel=0" frameborder="0" allowfullscreen></iframe>
</div>
</div>
But, is this really the best approach? I feel like there must be a better way to do this. I found a few posts where target="_blank" is added to the href (example here), but since I'm not opening a URL this hasn't worked for me so far.
Any help or advice on how to do this is appreciated. Thank you so much.