How can I detect if Flash is installed and if not, display a hidden div that informs the user?

If swfobject won’t suffice, or you need to create something a little more bespoke, try this: var hasFlash = false; try { hasFlash = Boolean(new ActiveXObject(‘ShockwaveFlash.ShockwaveFlash’)); } catch(exception) { hasFlash = (‘undefined’ != typeof navigator.mimeTypes[‘application/x-shockwave-flash’]); } It works with 7 and 8.

Download files like mega.co.nz

Mega uses several different methods to do this: (as of 27 Nov 2013) Filesystem API (Chrome/Firefox Extension polyfill) Adobe Flash SWF Filewriter (old browsers fallback) BlobBuilder (IE10/IE11) MEGA Firefox Extension (deprecated) Arraybuffer/Blob (in memory) + a[download] (for browsers that support a[download]) MediaSource (experimental streaming solution) Blob stored in IndexedDB storage + a[download] (Firefox 20+, improvement … Read more

Cross Browser Flash Detection in Javascript

I agree with Max Stewart. SWFObject is the way to go. I’d like to supplement his answer with a code example. This ought to to get you started: Make sure you have included the swfobject.js file (get it here): <script type=”text/javascript” src=”https://stackoverflow.com/questions/159261/swfobject.js”></script> Then use it like so: if(swfobject.hasFlashPlayerVersion(“9.0.115”)) { alert(“You have the minimum required flash … Read more

How to detect when a youtube video finishes playing?

This can be done through the youtube player API: http://jsfiddle.net/7Gznb/ Working example: <div id=”player”></div> <script src=”http://www.youtube.com/player_api”></script> <script> // create youtube player var player; function onYouTubePlayerAPIReady() { player = new YT.Player(‘player’, { width: ‘640’, height: ‘390’, videoId: ‘0Bmhjf0rKe8’, events: { onReady: onPlayerReady, onStateChange: onPlayerStateChange } }); } // autoplay video function onPlayerReady(event) { event.target.playVideo(); } // … Read more

HTML5 Local Storage fallback solutions [closed]

Pure JS based simple localStorage polyfill: Demo: http://jsfiddle.net/aamir/S4X35/ HTML: <a href=”#” onclick=”store.set(‘foo’,’bar’)”>set key: foo, with value: bar</a><br/> <a href=”#” onclick=”alert(store.get(‘foo’))”>get key: foo</a><br/> <a href=”#” onclick=”store.del(‘foo’)”>delete key: foo</a>​ JS: window.store = { localStoreSupport: function() { try { return ‘localStorage’ in window && window[‘localStorage’] !== null; } catch (e) { return false; } }, set: function(name,value,days) { … Read more

How to embed a SWF file in an HTML page?

The best approach to embed a SWF into an HTML page is to use SWFObject. It is a simple open-source JavaScript library that is easy-to-use and standards-friendly method to embed Flash content. It also offers Flash player version detection. If the user does not have the version of Flash required or has JavaScript disabled, they … Read more

How to determine user’s locale within browser?

The proper way is to look at the HTTP Accept-Language header sent to the server. This contains the ordered, weighted list of languages the user has configured their browser to prefer. Unfortunately this header is not available for reading inside JavaScript; all you get is navigator.language, which tells you what localised version of the web … Read more