Video auto play is not working in Safari and Chrome desktop browser

The best fix I could get was adding this code just after the </video> <script> document.getElementById(‘vid’).play(); </script> …not pretty but somehow works. UPDATE Recently many browsers can only autoplay the videos with sound off, so you’ll need to add muted attribute to the video tag too <video autoplay muted> … </video>

How can I force WebKit to redraw/repaint to propagate style changes?

I found some complicated suggestions and many simple ones that didn’t work, but a comment to one of them by Vasil Dinkov provided a simple solution to force a redraw/repaint that works just fine: sel.style.display=’none’; sel.offsetHeight; // no need to store this anywhere, the reference is enough sel.style.display=”; I’ll let someone else comment if it … Read more

Get the real width and height of an image with JavaScript? (in Safari/Chrome)

Webkit browsers set the height and width property after the image is loaded. Instead of using timeouts, I’d recommend using an image’s onload event. Here’s a quick example: var img = $(“img”)[0]; // Get my img elem var pic_real_width, pic_real_height; $(“<img/>”) // Make in memory copy of image to avoid css issues .attr(“src”, $(img).attr(“src”)) .load(function() … Read more

JavaScript: Is there a way to get Chrome to break on all errors?

I got trouble to get it so I post pictures showing different options: Chrome 101.0.4951.64 [27 May 2022] Very similar UI since at least Chrome 38.0.2125.111 [11 December 2014] In tab Sources : When button is activated, you can Pause On Caught Exceptions with the checkbox below: Previous versions Chrome 32.0.1700.102 [03 feb 2014] Chrome … Read more

Chrome / Safari not filling 100% height of flex parent

Solution Use nested flex containers. Get rid of percentage heights. Get rid of table properties. Get rid of vertical-align. Avoid absolute positioning. Just stick with flexbox all the way through. Apply display: flex to the flex item (.item), making it a flex container. This automatically sets align-items: stretch, which tells the child (.item-inner) to expand … Read more

Background color not showing in print preview

The Chrome CSS property -webkit-print-color-adjust: exact; works appropriately. However, making sure you have the correct CSS for printing can often be tricky. Several things can be done to avoid the difficulties you are having. First, separate all your print CSS from your screen CSS. This is done via the @media print and @media screen. Often … Read more

How can I debug javascript on Android?

Update: Remote Debugging Previously, console logging was the best option for debugging JavaScript on Android. These days with Chrome for Android remote debugging, we are able to make use of all the goodness of the Chrome for Desktop Developer Tools on Android. Check out https://developers.google.com/chrome-developer-tools/docs/remote-debugging for more information. Update: JavaScript Console You can also navigate … Read more

Convert Data URI to File then append to FormData

After playing around with a few things, I managed to figure this out myself. First of all, this will convert a dataURI to a Blob: function dataURItoBlob(dataURI) { // convert base64/URLEncoded data component to raw binary data held in a string var byteString; if (dataURI.split(‘,’)[0].indexOf(‘base64’) >= 0) byteString = atob(dataURI.split(‘,’)[1]); else byteString = unescape(dataURI.split(‘,’)[1]); // … Read more