Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problems were:</p> <ol> <li>iframe content comes from another domain</li> <li>iframe dimensions need to be adjusted for each video</li> </ol> <p>The solution based on <a href="https://stackoverflow.com/a/5660409/87015">omerkirk's answer</a> involves:</p> <ul> <li>Creating an iframe element</li> <li>Creating a dialog with <code>autoOpen: false, width: "auto", height: "auto"</code></li> <li>Specifying iframe source, width and height <em>before</em> opening the dialog</li> </ul> <p>Here is a rough outline of code:</p> <h3>HTML</h3> <pre><code>&lt;div class="thumb"&gt; &lt;a href="http://jsfiddle.net/yBNVr/show/" data-title="Std 4:3 ratio video" data-width="512" data-height="384"&gt;&lt;img src="http://dummyimage.com/120x90/000/f00&amp;text=Std+4-3+ratio+video" /&gt;&lt;/a&gt;&lt;/li&gt; &lt;a href="http://jsfiddle.net/yBNVr/1/show/" data-title="HD 16:9 ratio video" data-width="512" data-height="288"&gt;&lt;img src="http://dummyimage.com/120x90/000/f00&amp;text=HD+16-9+ratio+video" /&gt;&lt;/a&gt;&lt;/li&gt; &lt;/div&gt; </code></pre> <h3>jQuery</h3> <pre><code>$(function () { var iframe = $('&lt;iframe frameborder="0" marginwidth="0" marginheight="0" allowfullscreen&gt;&lt;/iframe&gt;'); var dialog = $("&lt;div&gt;&lt;/div&gt;").append(iframe).appendTo("body").dialog({ autoOpen: false, modal: true, resizable: false, width: "auto", height: "auto", close: function () { iframe.attr("src", ""); } }); $(".thumb a").on("click", function (e) { e.preventDefault(); var src = $(this).attr("href"); var title = $(this).attr("data-title"); var width = $(this).attr("data-width"); var height = $(this).attr("data-height"); iframe.attr({ width: +width, height: +height, src: src }); dialog.dialog("option", "title", title).dialog("open"); }); }); </code></pre> <p><a href="http://jsfiddle.net/H7uar/1/show/" rel="nofollow noreferrer"><strong>Demo here</strong></a> and <a href="http://jsfiddle.net/H7uar/1/" rel="nofollow noreferrer"><strong>code here</strong></a>. And <a href="http://salman-w.blogspot.com/2013/05/jquery-ui-dialog-examples.html#example-6" rel="nofollow noreferrer">another example along similar lines</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload