| | |
Check and redirect
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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:
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:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<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>
If you think you are the smartest, you definetly are not. But you can strive to be one. Cashwizz Affiliate network
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.
Hope this helps : - )
html Syntax (Toggle Plain Text)
<!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.
html Syntax (Toggle Plain Text)
<!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 have a question, though - is not a myApp init func. called by default, or how can that be achieved?
Thank you,
BoĊĦtjan
If you think you are the smartest, you definetly are not. But you can strive to be one. Cashwizz Affiliate network
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
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 ^^
Anyway; here goes
html Syntax (Toggle Plain Text)
<!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 ^^
Last edited by brechtjah; Dec 9th, 2008 at 5:52 am.
![]() |
Similar Threads
- custom .htaccess file 301 Redirect to non www form (Search Engine Optimization)
- Resources to check out before starting a new thread (Getting Started and Choosing a Distro)
- Redirects won't redirect... (Web Browsers)
- check box (ASP)
- Browser redirect/about:blank/other problems... (Viruses, Spyware and other Nasties)
- Doesn't check if username or email exits in database properly (ASP.NET)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Gen_ValidatorV31.js
- Next Thread: Help! Getting AJAX to work in a localhost environment using XAMPP installation
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate array automatically beta box browser bug calendar captchaformproblem cart close codes column cookies createrange() css cursor date debugger decimal dependent design dom download dropdown element embed enter error events firefox focus form frameworks getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 iframe images index java javascript javascripthelp2020 jawascriptruntimeerror jquery jsp libcurl listbox maps masterpage media menu microsoft mimic mp4 onmouseover paypal php player position post problem programming progressbar prototype redirect regex runtime safari scale scriptlets search security select software sql text textarea toggle unicode variables w3c webservice website window windowofwords windowsxp





