JavaScript in IE

  • Kurthead+1
  • Graduate
  • Graduate
  • Kurthead+1
  • Posts: 131

Post 3+ Months Ago

I'm testing my cross-browser compatibility in IE8. It's a 3 part calculator and all of the functions work except for the third part. I don't want to post the code, because it's a lot, but I will if it's necessary. First I just wanted to find out what are some common reasons that a JS function will work perfectly in FireFox and not work in IE8.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Posts: 6252
  • Loc: Seattle, WA

Post 3+ Months Ago

Before people start mindlessly chiming in with "LOLZ CUZ ITS IE", what exactly is going wrong? Saying "it doesn't work" doesn't provide a lot of context.
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

I agree, there are so many things that IE has issues on and there are somethings that IE does differently than other browsers and sometimes IE dose things different than IE lol

for example my old ajax script (I use jquery now)
JAVASCRIPT Code: [ Select ]
/**
*   This file is the ajax engine the script dose the xml connect and the send
*   request.
*
*   @author     William Gaines <sgscott87@gmail.com>
*   @copyright  2010-2014.
*
*/
 
/***********************************/
/*  AJAX Connect                   */
/***********************************/
 
// This function will make an AJAX conection
function ajax_connect() {
   
   // Make a xml http object varible
    var xml_http;
   
   // Try to find out which browser we are using
   try {
     
      // Firefox, Opera 8.0+, Safari
      xml_http = new XMLHttpRequest();
 
   } catch (e) {    // Internet Explorer
     
      // Try to figure out what version of IE we are using
      try {
         
         xml_http = new ActiveXObject("Msxml2.XMLHTTP");
     
      } catch (e) {
         
         try {
         
            xml_http = new ActiveXObject("Microsoft.XMLHTTP");
         
         } catch (e) {
           
            return false;
         
         }
     
      }
   
   }
   
   // Return our xml http object
   return xml_http;
 
}
 
 
/***********************************/
/*  AJAX Request                   */
/***********************************/
 
// This function will process our AJAX request
function ajax_request(xml_http, server_file, function_name, post_string) {
   
   // Setup our onreadystatechange function for ajax
   xml_http.onreadystatechange = function() {
     
      /*
          * 0 = uninitialized
         * 1 = loading
         * 2 = loaded
         * 3 = interactive
         * 4 = complete
      */
     
      // Check to see if our request is completed
      if(xml_http.readyState  == 4) {
         
         // Check for success
         if(xml_http.status  == 200) {
           
            // Execute the dynamic function we want to process
            eval(function_name + "('" + escape(xml_http.responseText) + "')");
 
         } else {
           
            // Trigger our error
            //error('We are currently experiencing issues on the server please try again at a later time.');
           
         }
         
      }
     
   }
   
   // Open a connection to our server file and send our info
   xml_http.open("POST", server_file, true);
   
   // Set the header info
   xml_http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
   
   // Send request
   xml_http.send(post_string);
 
}
 
  1. /**
  2. *   This file is the ajax engine the script dose the xml connect and the send
  3. *   request.
  4. *
  5. *   @author     William Gaines <sgscott87@gmail.com>
  6. *   @copyright  2010-2014.
  7. *
  8. */
  9.  
  10. /***********************************/
  11. /*  AJAX Connect                   */
  12. /***********************************/
  13.  
  14. // This function will make an AJAX conection
  15. function ajax_connect() {
  16.    
  17.    // Make a xml http object varible
  18.     var xml_http;
  19.    
  20.    // Try to find out which browser we are using
  21.    try {
  22.      
  23.       // Firefox, Opera 8.0+, Safari
  24.       xml_http = new XMLHttpRequest();
  25.  
  26.    } catch (e) {    // Internet Explorer
  27.      
  28.       // Try to figure out what version of IE we are using
  29.       try {
  30.          
  31.          xml_http = new ActiveXObject("Msxml2.XMLHTTP");
  32.      
  33.       } catch (e) {
  34.          
  35.          try {
  36.          
  37.             xml_http = new ActiveXObject("Microsoft.XMLHTTP");
  38.          
  39.          } catch (e) {
  40.            
  41.             return false;
  42.          
  43.          }
  44.      
  45.       }
  46.    
  47.    }
  48.    
  49.    // Return our xml http object
  50.    return xml_http;
  51.  
  52. }
  53.  
  54.  
  55. /***********************************/
  56. /*  AJAX Request                   */
  57. /***********************************/
  58.  
  59. // This function will process our AJAX request
  60. function ajax_request(xml_http, server_file, function_name, post_string) {
  61.    
  62.    // Setup our onreadystatechange function for ajax
  63.    xml_http.onreadystatechange = function() {
  64.      
  65.       /*
  66.           * 0 = uninitialized
  67.          * 1 = loading
  68.          * 2 = loaded
  69.          * 3 = interactive
  70.          * 4 = complete
  71.       */
  72.      
  73.       // Check to see if our request is completed
  74.       if(xml_http.readyState  == 4) {
  75.          
  76.          // Check for success
  77.          if(xml_http.status  == 200) {
  78.            
  79.             // Execute the dynamic function we want to process
  80.             eval(function_name + "('" + escape(xml_http.responseText) + "')");
  81.  
  82.          } else {
  83.            
  84.             // Trigger our error
  85.             //error('We are currently experiencing issues on the server please try again at a later time.');
  86.            
  87.          }
  88.          
  89.       }
  90.      
  91.    }
  92.    
  93.    // Open a connection to our server file and send our info
  94.    xml_http.open("POST", server_file, true);
  95.    
  96.    // Set the header info
  97.    xml_http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  98.    
  99.    // Send request
  100.    xml_http.send(post_string);
  101.  
  102. }
  103.  
  • Kurthead+1
  • Graduate
  • Graduate
  • Kurthead+1
  • Posts: 131

Post 3+ Months Ago

Yeah I figured that you would need more information, but I didn't want to post all that JS code, so I was just going to wait on your guys' responses and see what you needed. The function just doesn't work. There is a button that executes the functions on each calculator and they work perfectly in Firefox. I very recently considered the possibility that it's a CSS issue, since that's the biggest problem with IE, because the DIV's that contain the results of the functions that these buttons execute, have overflow:hidden; set, so it's possible, however unlikely, that it's a positioning issue. So, I'm going to rule that out in a minute.
I'll just PM Scott the link first. Check it out in Firefox, so you can see how everything is supposed to work. The JS file is called calcs.js as a link in the head. So view source and check it out. There are comments throughout my code so, check under the comment that says "***Function for Third Calculator***"
  • Kurthead+1
  • Graduate
  • Graduate
  • Kurthead+1
  • Posts: 131

Post 3+ Months Ago

spork wrote:
Before people start mindlessly chiming in with "LOLZ CUZ ITS IE", what exactly is going wrong? Saying "it doesn't work" doesn't provide a lot of context.



Just got IE10 with my new laptop and it's incredible. I think it's better than FireFox and the others. It runs faster, and has the CSS capabilities that the earlier versions were lacking.
  • Kurthead+1
  • Graduate
  • Graduate
  • Kurthead+1
  • Posts: 131

Post 3+ Months Ago

I was able to fix one JavaScript error that was occurring only in IE's earlier than 9. The browser, I think, was confusing variables with methods somehow, so a I just had to had "var" to a couple of my variables to fix it.
  • Kurthead+1
  • Graduate
  • Graduate
  • Kurthead+1
  • Posts: 131

Post 3+ Months Ago

Okay, now I have all of the errors fixed. All of the problems with it running in IE were not having "var" in front of certain variables. I didn't know that it was necessary in any browser.

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 140 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.