Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>The Hack-tastic solution</h2> <p>Seriously. If anyone has a better solution, please tell me.</p> <p>When JWPlayer detects an HTML 5 compliant browser, it renders the HTML 5 version of the video player. The control-bar buttons are <code>&lt;button&gt;</code> elements, which by default cause the ASP.NET validators to fire, which in turn causes a post-back.</p> <p>Using Javascript/JQuery, I attempted to set the <code>onclick</code> attribute of all buttons to <code>return false;</code> in the <code>window.onload</code> event. However, for some reason, the player hasn't been rendered at that point in the page's life cycle - the JQuery selector <code>$("button")</code> returned 0 elements.</p> <p>So here's what I ended up doing. As noted, this is hack-tacular and I hate it. Hopefully Longtail fixes this soon.</p> <pre><code>&lt;div onclick="disableButtons(); return false;" &gt; &lt;div id='my-video'&gt;&lt;/div&gt; &lt;script type='text/javascript'&gt; jwplayer('my-video').setup({ file: '/videos/Penultimate_Md.mp4', image: '/videos/penultimate_first.png', width: '480', height: '270' }); function disableButtons() { var buttons = $("my-video button"); buttons.attr('onclick', 'function () { return false; }'); &lt;/script&gt; &lt;/div&gt; </code></pre> <p>So, whenever a user clicks on the <code>&lt;div&gt;</code> containing the player, all buttons are set to <code>return false;</code>. <strike><strong>NB</strong> This applys to ALL buttons on the page. If you have any other buttons on your page, it will affect them as well.</strike> I incorporated @goodwince's suggestion, which only targets buttons within the specified <code>div</code>.</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.
 

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