• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 445
  • Last Modified:

Flash mobile redirect doesnt work after ios 5 updates

The redirect coding that I have been using no longer works in default safari, I cant seem to find a lot of information on it either. I have attached the coding below.
It also still works in my atomic web browser, with identify as a ipad mobile browser selected. Maybe there is a better code to use with the new safari.

Randy



<script type="text/javascript"> 
	if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1) || (navigator.userAgent.indexOf('iPad') != -1)) {
		document.location = "http://www.google.com/mobile.htm";
	}
</script>

Open in new window

0
CREATiVENESS
Asked:
CREATiVENESS
  • 2
1 Solution
 
dgofmanCommented:
Probably you will use some script for dynamically detecting flash version and plug-in some this like what I have bellow (my version of SWFObject.js). In this case modify and if version is incorrect or plug-in doesn't exist redirect to HTML version. The differences between Mobile devices and web browser you cannot update or install a Flash Player if version is incorrect, so don’t reproduce problem testing this scenario.

// -----------------------------------------------------------------------------
// Globals 
// Major version of Flash required
var requiredMajorVersion = 10;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;

var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;			
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
			var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		try {
			// version will be set for 7.X or greater players
			var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
			flashVer = axo.GetVariable("$version");
		} catch (e) {
			try {
				// version will be set for 6.X players only
				var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
				
				// installed player is some revision of 6.0
				// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
				// so we have to be careful. 
				
				// default to the first public version
				flashVer = "WIN 6,0,21,0";

				// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
				axo.AllowScriptAccess = "always";

				// safe to call for 6.0r47 or greater
				flashVer = axo.GetVariable("$version");
			} catch (e) {
				try {
					// version will be set for 4.X or 5.X player
					var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
					flashVer = axo.GetVariable("$version");
				} catch (e) {
					try {
						// version will be set for 3.X player
						var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
						flashVer = "WIN 3,0,18,0";
					} catch (e) {
						try {
							// version will be set for 2.X player
							var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
							flashVer = "WIN 2,0,0,11";
						} catch (e) {}
					}
				}
			}
		}
	}
	return flashVer;
}

function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function createSWF(src,  flashvars)
{
	// Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
	var hasProductInstall = DetectFlashVer(6, 0, 65);

	// Version check based upon the values defined in globals
	var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

	var flashParams = {
		allowFullScreen:true,
		align:"middle",
		quality:"high",
		bgcolor:"#FFFFFF",
		allowScriptAccess:"always",
		type:"application/x-shockwave-flash"
	};

	// Check to see if a player with Flash Product Install is available and the version does not meet the requirements for playback
	if ( hasProductInstall && hasRequestedVersion ) {
		flashParams.src = src + '.swf';
		flashParams.flashvars = flashvars;
		document.write( flashParamsToString(src, flashParams) );
	} else {  // flash is too old or we can't detect the plugin
		document.location.href = "http://www.google.com/mobile.htm";
	}
}

function flashParamsToString(id, flashParams){
	var str = 'width="100%" height="100%" ';
	if (isIE && isWin && !isOpera)
	{
		str = '<object id="' + id + '" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ' + str;
		for (var i in flashParams)
			str += '><param name="' + i + '" value="' + flashParams[i] + '" /';
		str += '></object>';
	} else {
		str = '<embed id="' + id + '" pluginspage="http://www.adobe.com/go/getflashplayer" ' + str;
		for (var i in flashParams)
			str += i + '="' + flashParams[i] + '" ';
		str += '> </embed>';
	}
	return str;
}

Open in new window

0
 
CREATiVENESSAuthor Commented:
Thanks DG,
but I need to redirect to an Ipad version seperate from a iphone version on some sites.
0
 
Jen0910Commented:
Here is what I have used, works pretty well. Has a main and then fallback option to detect the exact devices you are looking for, and more devices can be added as you see fit.

<script language="javascript" type="text/javascript">
var HandsetDetection = {
	ismobile : false,
	istablet : false,
	isconsole : false,
	urls : ["www.domain.com","www.domain.com/mobile"],
	
	redirect: function() {
		// Smart Redirection - if referrer domain is in url list then do nothing - its internal.
		if ("0" == "1") {
			var refurl = "";
			if (document.referrer) {
				refurl = document.referrer.toString();
			} else if (window.opener && !window.opener.closed && window.opener.location) {
				try {
					refurl = window.opener.location.toString();
				} catch (err) {
					refurl = "";
				}
			}
			if (refurl.length > 0) {
				refurl = refurl.toLowerCase().replace(/http:\/\//i, "").split("/", 1);
				for(var i in this.urls) {
					if (this.urls[i].toLowerCase().indexOf(refurl) > -1) {
						// Found match - quit.
						return 1;
					}
				}
			}
		}
		
		// Redirection rules.
// Mobile Site
if (   (this.ismobile == true ) || (this.istablet == true ) ) { window.location = "http://www.domain.com/mobile"; return 1; }
		
	}
}

HandsetDetection.redirect();
</script>


<script language="javascript" type="text/javascript">
	var deviceIphone = "iphone";
        var deviceIpod = "ipod"; 
		var deviceIpad = "ipad";
		var devicePalm = "palm";
        var deviceBB = "blackberry";
		var deviceWinMob = "windows ce";
		var deviceAndroid = "android";


        var startIndex = window.location.href.indexOf("=")+1;
        if(window.location.href.substring(startIndex)!= "main")
        {
            //Initialize our user agent string to lower case.
			var uagent = navigator.userAgent.toLowerCase();
            
			//**************************
			// Detects if the current device is an iPhone.
			if (uagent.search(deviceIphone) > -1) {
                window.location="http://www.domain.com/mobile"; 
			}
			//**************************
			// Detects if the current device is an iPod Touch.
            if (uagent.search(deviceIpod) > -1) {
               window.location="http://www.domain.com/mobile";
            }
			//**************************
			// Detects if the current device is an iPad tablet.
            if (uagent.search(deviceIpad ) > -1) {
                window.location="http://www.domain.com/mobile"; 
           }
			//**************************
			// Detects if the current device is a PalmOS device.
            if (uagent.search(devicePalm) > -1) {
                window.location="http://www.domain.com/mobile";
            }
			//**************************
			// Detects if the current device is a BlackBerry of some sort.
            if (uagent.search(deviceBB) > -1) {
                window.location="http://www.domain.com/mobile/home.html";
            }
			//**************************
			// Detects if the current device is a Windows Mobile device.
            if (uagent.search(deviceWinMob) > -1) {
                window.location="http://www.domain.com/mobile";
            }
			//**************************
			// Detects if the current device is an Android OS-based device.
            if (uagent.search(deviceAndroid) > -1) {
               window.location="http://www.domain.com/mobile";
            }
       }
    </script>

Open in new window

0
 
CREATiVENESSAuthor Commented:
Jen after checking that yours didnt work either, I found in the settings that javascript wasnt enabled by default. After I enabled it then my old code continued to work.

Randy
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now