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

I spent quite a lot of time trying to figure out why video embedded like here: <video height=”256″ loop autoplay muted controls id=”vid”> <source type=”video/mp4″ src=”https://stackoverflow.com/questions/17994666/video_file.mp4″></source> <source type=”video/ogg” src=”video_file.ogg”></source> </video> starts playing automatically once the page is loaded in FireFox but cannot do autoplay in Webkit based browsers. This only happened on some random pages. … Read more

Invalid date in safari

alert(new Date(‘2010-11-29′)); chrome, ff doesn’t have problems with this, but safari cries “invalid date”. Why ? edit : ok, as per the comments below, I used string parsing and tried this : alert(new Date(’11-29-2010′)); //doesn’t work in safari alert(new Date(’29-11-2010′)); //doesn’t work in safari alert(new Date(‘2010-29-11’)); //doesn’t work in safari edit Mar 22 2018 : … Read more

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

I have some trivial JavaScript to effect a style change: sel = document.getElementById(‘my_id’); sel.className = sel.className.replace(/item-[1-9]-selected/,’item-1-selected’); return false; This works fine with the latest versions of FF, Opera and IE, but fails on the latest versions of Chrome and Safari. It affects two descendants, which happen to be siblings. The first sibling updates, but the … Read more

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

I am creating a jQuery plugin. How do I get the real image width and height with Javascript in Safari? The following works with Firefox 3, IE7 and Opera 9: var pic = $(“img”) // need to remove these in of case img-element has set width and height pic.removeAttr(“width”); pic.removeAttr(“height”); var pic_real_width = pic.width(); var … Read more

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

Update at 2018.10.31 This bug has been fixed in iOS 12.1, have a good day~ I found a problem with Array’s value state in the newly released iOS 12 Safari, for example, code like this: <!DOCTYPE html> <html> <head> <meta charset=”utf-8″> <meta name=”viewport” content=”width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0″> <title>iOS 12 Safari bugs</title> <script type=”text/javascript”> window.addEventListener(“load”, function () … Read more