What does the shrink-to-fit viewport meta attribute do?

It is Safari specific, at least at time of writing, being introduced in Safari 9.0. From the “What’s new in Safari?” documentation for Safari 9.0: Viewport Changes Viewport meta tags using “width=device-width” cause the page to scale down to fit content that overflows the viewport bounds. You can override this behavior by adding “shrink-to-fit=no” to … Read more

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 to detect if the OS is in dark mode in browsers?

The new standard is registered on W3C in Media Queries Level 5. NOTE: currently only available in Safari Technology Preview Release 68 In case user preference is light: /* Light mode */ @media (prefers-color-scheme: light) { body { background-color: white; color: black; } } In case user preference is dark: /* Dark mode */ @media … Read more

Is there a way to apply styles to Safari only?

UPDATED FOR MONTEREY & SAFARI 15 (early 2022 Update) * PLEASE PLEASE — If you are having trouble, and really want to get help or help others by posting a comment about it, Post Your Browser and Device (MacBook/IPad/etc… with both browser and OS version numbers!) Claiming none of these work is not accurate (and … Read more

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

Array state will be cached in iOS 12 Safari. Is it a bug or feature?

It’s definitely a BUG! And it’s a very serious bug. The bug is due to the optimization of array initializers in which all values are primitive literals. For example, given the function: function buildArray() { return [1, null, ‘x’]; } All returned array references from calls to buildArray() will link to the same memory, and … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)