Multiple onload problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • burtonfigg
    New Member
    • Mar 2008
    • 32

    Multiple onload problem

    On this page:
    Use the jimpix username generator to create unique and memorable usernames for Instagram, Twitter, Youtube and popular social media sites


    When viewed in IE6, only the wallppaper ajax section (which is 1 of 4 ajax sections, along with ecards / news / photo ecards and wallpapers), loads.

    But in Firefox, they all load, when first loading the page.

    I am using this method to load all of the functions on first loading the page:


    My javascript functions are at the bottom of the page. Could the problem be to do with my first function - since this issue seems to be browser specific.

    Thanks

    Code:
    function GetXmlHttpObject() {
      var xmlhttp;
      if (window.XMLHttpRequest) { // Mozilla, Safari, Opera...
        xmlhttp = new XMLHttpRequest();
        //if (xmlhttp.overrideMimeType) xmlhttp.overrideMimeType('text/xml');
      } else if (window.ActiveXObject) { // IE
          try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
          } catch (e) {
              try {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
              } catch (e) {}
          }
      }
      if (!xmlhttp) {
        alert('Cannot create an XMLHTTP instance');
        return false;
      }
      return xmlhttp;
    }
    
    var http = GetXmlHttpObject();
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    womAdd() requires strings. Put quotes around the function call.

    Comment

    • burtonfigg
      New Member
      • Mar 2008
      • 32

      #3
      Thanks for the reply. I have changed that, but for some reason, the page works fine in Firefox, when it first loads, but again, in IE6, it only displays the last of the 4 functions - the one in bold.

      [HTML]<script type="text/javascript" src="_wom.js"></script>
      <script type="text/javascript">
      womAdd("sendReq uest(MyCurrentV ar + ',' + MyCurrentCat)") ;
      womAdd("sendPho toRequest(MyPho toVar)");
      womAdd("sendNew sRequest(MyNews Var)");
      womAdd("sendWPR equest(MyWPVar) ");
      womOn();
      </script>[/HTML]

      And if I comment out the bold line (calling the 'sendWPRequest' function), IE6 will display the 3rd function, but ignore the 1st and 2nd!

      I uploaded the revised page again:
      Use the jimpix username generator to create unique and memorable usernames for Instagram, Twitter, Youtube and popular social media sites


      Thanks again

      Jim

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        It seems that IE6 is overwriting the onload. Try using this script and see if it makes a difference.

        Comment

        • burtonfigg
          New Member
          • Mar 2008
          • 32

          #5
          Thanks acoder, again, for your helpful suggestion and feedback.

          I gave it a try, but would you believe it, just the same result:
          http://jimpix.co.uk/default-ajax1a.asp

          I think that's the 4th method I've tried now:

          1. multiple list on the onload in the body tag:
          [HTML]<body onload="sendReq uest(MyCurrentV ar + ',' + MyCurrentCat);s endPhotoRequest (MyPhotoVar);se ndNewsRequest(M yNewsVar);sendW PRequest(MyWPVa r);">[/HTML]

          2. Use the window.onload:
          Code:
          window.onload = function()
          {
          	sendRequest(MyCurrentVar + ',' + MyCurrentCat)
          	sendPhotoRequest(MyPhotoVar)
          	sendNewsRequest(MyNewsVar)
          	sendWPRequest(MyWPVar)
          }
          3. Use the NetLobo option:
          http://www.netlobo.com/wom.html

          4. Use Simon Wilson's option:
          http://simon.incutio.c om/code/js/addloadevent/

          Do you think it just can't be done?

          Thanks again for your help

          Jim

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Then it must be that you're reusing the http-request object, so it doesn't finish one and starts another. Either use different variables for each one or wait for one to finish before making another request using the same variable.

            Comment

            • burtonfigg
              New Member
              • Mar 2008
              • 32

              #7
              Dear acoder,

              you are a star! Thank you so much for your help. That was the problem all along. I created different variables for each function, and it works a treat now, in IE6 and Firefox. Thank you again, what a helpful person!

              Jim

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                You're welcome. Glad it's working now :)

                Comment

                Working...