Home | Web Design | App / Game development | Flash | Flash Games | Graphic Illustration | Technical Illustration | Contact | Site Map    Twitter
  Galaxy Graphics Limited

Technical InformationSWF Knowledgebase: Detecting mobile devices and sending the user to the app store if no Flash support

1) Include WURLF.js in your page header

<script type="text/javascript" src="//wurfl.io/wurfl.js"></script>

You can read more about WURLF on it's homepage, http://wurfl.io/

2) In the HTML page

<script type="text/javascript">
   var element_device = document.getElementById('device');
	var element_message = document.getElementById('message');
	var element_flash = document.getElementById('flash_content');
	is_iOS = false; 
  if (navigator.userAgent.match(/like Mac OS X/i)) {
  	is_iOS = true;
            element_device.innerHTML = "You're using an Apple mobile device";
            element_device.innerHTML = "<a href='https://itunes.apple.com/us/app
            /fat-santa-pie-eater/id707367884?mt=8'>You can get the app 
            version of this Flash game on the Apple App store here</a>";
            element_flash.style.display = 'none';
      } else {
            // Lets assume that Windows Mobile does not exist, which it practically doesn't.
            element_device.innerHTML = "You're using an Android mobile device";
            element_device.innerHTML = "<a href='https://play.google.com/store/apps/details?
            id=air.fatsanta1.A06android&hl=en_GB'>You can get the app 
            version of this Flash game on the Google Play store here</a>";
            element_flash.style.display = 'none';
  } else {
 	element_device.innerHTML = "Congratulations, you're using a proper computer";
  	// Do nothing. User has full computer, and we're assuming that also means Flash

3) End result

The HTML elements below are hidden and/or rewritten depending on what device you're using

Here's what device you're using

If you're on a tablet/phone/mobile device, Javascript will write this paragraph into a link to the app store

DIV ID = flash_content. This message will be hidden if you are using mobile device. Wrap your Flash in this div so it won't show a large space or anything to your mobile users

Site content Copyright © 2001-2014 Galaxy Graphics Limited. | Privacy Policy | Terms of use