/* From http://www.jquery4u.com/snippets/url-parameters-jquery/ */ /* Usage: $('#city').val(decodeURIComponent($.urlParam('city'))); */ $.urlParam = function(name){ var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href); if (results==null){ return null; } else{ return results[1] || 0; } }; /* Update URL Param */ /* Josh Palmeri, 1/29/2018 */ /* Usage: $.updateURL('play','11234'); */ $.updateURL = function(param,val) { if (history.pushState) { var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?'+param+'='+val; window.history.pushState({path:newurl},'',newurl); } } // Programmatically update the browser URL on the desired listener $('.my-element').on('click touchstart', function(){ $.updateURL('play',thisID); } // Get URL param on page load and trigger the video play $(document).ready(function(){ var playParam = $.urlParam('play'); if(playParam!=''&&playParam!=null&&playParam!='undefined'&&playParam!=undefined) { var playID = '#'+playParam; $(playID).trigger('click'); } });