Hi,

N00b as I am, I have a little problem:

I have a gamesite. When a user clicks on a game, a Js script has to check if he has our app installed and if not, it redirects him to our landing page, where he can install that app.
This is my code so far, but it does not work:

<html>
<head>
<script language="javascript">
myApp=0;
function myAppInit(tool)
{ myApp=1

}
</script>


<script language="javascript">
function checkmyApp(){
if(myApp!=1) window.location.href="http://mydomain.com/MediaGate/tabid/199/language/en-US/Default.aspx";}


</script>
</head>
<body>
<a href="myfile.swf">Click here</a>
</body>
</html>

I'm not sure how you are going to check for that application so I just corrected some of your code and made it redirect, mind you that now the user doesn't have the needed application by standard. If you want to change that, you'll have to call a function, which is probably the myAppInit() one to change that value.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<script type="text/javascript">
		myApp=0;
		function myAppInit(tool) {
			myApp=1;
		}

		function checkMyApp(){
			if(myApp!=1) {
				window.location.href="http://mydomain.com/MediaGate/tabid/199/language/en-US/Default.aspx";
			}
		}
		</script>
	</head>
	
	<body>
		<a href="#" onClick="javascript:checkMyApp();">Click here</a>
	</body>
</html>

Hope this helps : - )

I'm not sure how you are going to check for that application so I just corrected some of your code and made it redirect, mind you that now the user doesn't have the needed application by standard. If you want to change that, you'll have to call a function, which is probably the myAppInit() one to change that value.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<script type="text/javascript">
		myApp=0;
		function myAppInit(tool) {
			myApp=1;
		}

		function checkMyApp(){
			if(myApp!=1) {
				window.location.href="http://mydomain.com/MediaGate/tabid/199/language/en-US/Default.aspx";
			}
		}
		</script>
	</head>
	
	<body>
		<a href="#" onClick="javascript:checkMyApp();">Click here</a>
	</body>
</html>

Hope this helps : - )

Hey, thx for your help :)
I have a question, though - is not a myApp init func. called by default, or how can that be achieved?
Thank you,
BoĊĦtjan

After some heavy googling I came up with this; however the IE part does not work I'm afraid, in my IE it always returns false. I have been trying quite everything, but I don't know that much about VBScript, which is necessary to check for the Flash plugin in IE.
Anyway; here goes

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<script type="text/javascript">
			function checkForFlash() {
				var browser = navigator.appName;
				var flashVersion;
				var hasFlash = navigator.mimeTypes["application/x-shockwave-flash"];
				if(hasFlash) {
					document.getElementById('divInfo').innerHTML = "You have the Flash Player plugin.";
				}
				else if(browser == "Microsoft Internet Explorer") {
					hasFlash = false;
					MSDetect = "true";
					document.write('<script type="text/vbscript"\> \n');
					document.write('on error resume next \n');
					document.write('If MSDetect = "true" Then \n');
					document.write('  For i = 2 to 10 \n');
					document.write('    If (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & i))) Then \n');
					document.write('      hasFlash = true \n');
					document.write('      flashVersion = i \n');
					document.write('    End If \n ');
					document.write('  Next \n');
					document.write('End If \n');
					document.write('</script\> \n');
					
					alert(hasFlash);
				}
			}
		</script>
	</head>
	
	<body onLoad="javascript:checkForFlash();">
		<div id="divInfo" style="width: 300px; height: 200px; background-color: #bbbbbb;">
		</div>
	</body>
</html>

I guess it has something to do with the hasFlash variable being set to true for the right version, but when the for loop loops another time it just resets it back to false. However, I can't solve this myself, I might google somewhat later but now I have to study for my exams today ^^

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.