Video Backgrounds

Video backgrounds are pretty straightforward.  Add a <video> element somewhere near the beginning or end of the body element: <video id=”bgvid” poster=”bgvid.jpg” autoplay muted loop><source src=”bgvid.mp4″ type=”video/mp4″></video> The autoplay, muted, and loop attributes are appropriate for a background, and the poster attribute is a still from the first frame of the video, something to display […]

Auto Tab Script to Advance Users to the Next Input Field

JavaScript <script>   // auto tab   (function(){     var maxLengthInputs = document.querySelectorAll(‘#myform input[maxlength]’);     for(var i=0, l = maxLengthInputs.length; i<l; i++){         maxLengthInputs[i].addEventListener(‘input’, autotab );     }     function autotab(e){         if ( this.value.length == this.maxLength){             var allInputs = document.querySelectorAll(‘#myform input’);             var index = 1 + […]

Warn users before they exit a form

document.addEventListener(‘DOMContentLoaded’, function(){     function exitWarning(e){         e.preventDefault();     }     function setExitWarning(){         window.addEventListener(‘beforeunload’, exitWarning );         this.removeEventListener(‘change’, setExitWarning );     }     var forms = document.querySelectorAll(‘main form’);          for ( var i = 0, l = forms.length; i < l; i++ ) {         forms[i].addEventListener(‘change’, setExitWarning );    […]