943,741 Members | Top Members by Rank

Ad:
Dec 8th, 2008
0

Check and redirect

Expand Post »
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>
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
elbuhleini is offline Offline
17 posts
since Apr 2008
Dec 8th, 2008
0

Re: Check and redirect

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)
  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 : - )
Reputation Points: 26
Solved Threads: 9
Junior Poster in Training
brechtjah is offline Offline
92 posts
since Nov 2008
Dec 9th, 2008
0

Re: Check and redirect

Click to Expand / Collapse  Quote originally posted by brechtjah ...
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)
  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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
elbuhleini is offline Offline
17 posts
since Apr 2008
Dec 9th, 2008
0

Re: Check and redirect

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
html Syntax (Toggle Plain Text)
  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.
Reputation Points: 26
Solved Threads: 9
Junior Poster in Training
brechtjah is offline Offline
92 posts
since Nov 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Gen_ValidatorV31.js
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Help! Getting AJAX to work in a localhost environment using XAMPP installation





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC