Check and redirect

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Apr 2008
Posts: 17
Reputation: elbuhleini is an unknown quantity at this point 
Solved Threads: 0
elbuhleini's Avatar
elbuhleini elbuhleini is offline Offline
Newbie Poster

Check and redirect

 
0
  #1
Dec 8th, 2008
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:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <script language="javascript">
  4. myApp=0;
  5. function myAppInit(tool)
  6. { myApp=1
  7.  
  8. }
  9. </script>
  10.  
  11.  
  12. <script language="javascript">
  13. function checkmyApp(){
  14. if(myApp!=1) window.location.href="http://mydomain.com/MediaGate/tabid/199/language/en-US/Default.aspx";}
  15.  
  16.  
  17. </script>
  18. </head>
  19. <body>
  20. <a href="myfile.swf">Click here</a>
  21. </body>
  22. </html>
If you think you are the smartest, you definetly are not. But you can strive to be one. Cashwizz Affiliate network
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 91
Reputation: brechtjah is an unknown quantity at this point 
Solved Threads: 9
brechtjah's Avatar
brechtjah brechtjah is offline Offline
Junior Poster in Training

Re: Check and redirect

 
0
  #2
Dec 8th, 2008
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.

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <script type="text/javascript">
  5. myApp=0;
  6. function myAppInit(tool) {
  7. myApp=1;
  8. }
  9.  
  10. function checkMyApp(){
  11. if(myApp!=1) {
  12. window.location.href="http://mydomain.com/MediaGate/tabid/199/language/en-US/Default.aspx";
  13. }
  14. }
  15. </script>
  16. </head>
  17.  
  18. <body>
  19. <a href="#" onClick="javascript:checkMyApp();">Click here</a>
  20. </body>
  21. </html>

Hope this helps : - )
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 17
Reputation: elbuhleini is an unknown quantity at this point 
Solved Threads: 0
elbuhleini's Avatar
elbuhleini elbuhleini is offline Offline
Newbie Poster

Re: Check and redirect

 
0
  #3
Dec 9th, 2008
Originally Posted by brechtjah View Post
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.

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <script type="text/javascript">
  5. myApp=0;
  6. function myAppInit(tool) {
  7. myApp=1;
  8. }
  9.  
  10. function checkMyApp(){
  11. if(myApp!=1) {
  12. window.location.href="http://mydomain.com/MediaGate/tabid/199/language/en-US/Default.aspx";
  13. }
  14. }
  15. </script>
  16. </head>
  17.  
  18. <body>
  19. <a href="#" onClick="javascript:checkMyApp();">Click here</a>
  20. </body>
  21. </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
If you think you are the smartest, you definetly are not. But you can strive to be one. Cashwizz Affiliate network
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 91
Reputation: brechtjah is an unknown quantity at this point 
Solved Threads: 9
brechtjah's Avatar
brechtjah brechtjah is offline Offline
Junior Poster in Training

Re: Check and redirect

 
0
  #4
Dec 9th, 2008
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
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <script type="text/javascript">
  5. function checkForFlash() {
  6. var browser = navigator.appName;
  7. var flashVersion;
  8. var hasFlash = navigator.mimeTypes["application/x-shockwave-flash"];
  9. if(hasFlash) {
  10. document.getElementById('divInfo').innerHTML = "You have the Flash Player plugin.";
  11. }
  12. else if(browser == "Microsoft Internet Explorer") {
  13. hasFlash = false;
  14. MSDetect = "true";
  15. document.write('<script type="text/vbscript"\> \n');
  16. document.write('on error resume next \n');
  17. document.write('If MSDetect = "true" Then \n');
  18. document.write(' For i = 2 to 10 \n');
  19. document.write(' If (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & i))) Then \n');
  20. document.write(' hasFlash = true \n');
  21. document.write(' flashVersion = i \n');
  22. document.write(' End If \n ');
  23. document.write(' Next \n');
  24. document.write('End If \n');
  25. document.write('</script\> \n');
  26.  
  27. alert(hasFlash);
  28. }
  29. }
  30. </script>
  31. </head>
  32.  
  33. <body onLoad="javascript:checkForFlash();">
  34. <div id="divInfo" style="width: 300px; height: 200px; background-color: #bbbbbb;">
  35. </div>
  36. </body>
  37. </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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC