Track the response status of a IFrame

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    Track the response status of a IFrame

    I have an IFrame in my page. From this i running a script to load the IFrame and to track whether the IFrame gets loaded properly or not.
    How can i track this ...can anyone help me to do this. .. ?
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Use the onload event.

    Comment

    • dmjpro
      Top Contributor
      • Jan 2007
      • 2476

      #3
      Originally posted by acoder
      Use the onload event.
      Yeah that i thought and tried to do but failed ....
      Basically the IFrame is getting updated asynchronously by Ajax ..what should i be doing ?

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Post the code that you're testing with.

        Comment

        • gits
          Recognized Expert Moderator Expert
          • May 2007
          • 5388

          #5
          an analogue thing to an onload-event is the callback of an async AJAX-request ... this is called (you may consider it as 'fired' if you like) when the response is ready to use ...

          kind regards

          Comment

          • dmjpro
            Top Contributor
            • Jan 2007
            • 2476

            #6
            Originally posted by gits
            an analogue thing to an onload-event is the callback of an async AJAX-request ... this is called (you may consider it as 'fired' if you like) when the response is ready to use ...

            kind regards
            Ok let me explain ....
            I am testing the code with site Orkut .....
            There is an IFrame and Iframe is getting loaded by asyn Ajax call. All these are taking care of by site itself ..i am running a script outside of this ...i have no control over the JS code of the site .....How can i track the response status when IFrame gets loaded successfully ... Is it possible ... ????

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              Is the site loaded into the iframe from the same domain?

              Comment

              • rnd me
                Recognized Expert Contributor
                • Jun 2007
                • 427

                #8
                if the iframe is in a different domain than the html page pointing to/containing your script, then no.

                Comment

                • dmjpro
                  Top Contributor
                  • Jan 2007
                  • 2476

                  #9
                  Originally posted by rnd me
                  if the iframe is in a different domain than the html page pointing to/containing your script, then no.
                  No no ..this is the same domain .....

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    #10
                    Post your code or a link to a test page. Can you get the response from the Ajax call? How did you use the onload event?

                    Comment

                    • dmjpro
                      Top Contributor
                      • Jan 2007
                      • 2476

                      #11
                      Originally posted by acoder
                      Post your code or a link to a test page. Can you get the response from the Ajax call? How did you use the onload event?
                      I am not using onLoad event because page is loaded by Ajax Call.
                      And one more thing do you have any Orkut Account only then i can do further communication with you ... ;)

                      Comment

                      • acoder
                        Recognized Expert MVP
                        • Nov 2006
                        • 16032

                        #12
                        No, I don't have an Orkut account.

                        Why can't you post the JavaScript code that you're using? If it's loaded using Ajax, why not use the status property (OK) to mean that it's loaded? If it takes a long time to load, you can still set the onload event by accessing the iframe. You could also check the document exists.

                        Comment

                        • dmjpro
                          Top Contributor
                          • Jan 2007
                          • 2476

                          #13
                          Originally posted by acoder
                          No, I don't have an Orkut account.

                          Why can't you post the JavaScript code that you're using? If it's loaded using Ajax, why not use the status property (OK) to mean that it's loaded? If it takes a long time to load, you can still set the onload event by accessing the iframe. You could also check the document exists.
                          The Ajax function is taken care by Orkut itself ...i can't interfere the code ...I think without touching it's Ajax call back function i can't track the status OK.
                          Anyway ..this is my code ......


                          Code:
                          JavaScript:var _win=window.frames['orkutFrame'];var doc = window.frames['orkutFrame'].document;if(typeof top.win!='undefined' && !top.win.closed) top.win.focus();else top.win = window.open('','win_1234567890','height='+screen.height+',width='+screen.width+',menubar=no,location=no,resizable=yes,scrollbars=yes,status=no');image = top.win.document.createElement('img');image.src = doc.getElementById('m1224670822579').src;top.win.document.body.appendChild(image);while(1)if(doc.getElementById('nav_right').src.indexOf('disable')==-1){_win.galleryManager.next();alert('press OK, when next pic loaded..');image = top.win.document.createElement('img');image.src = doc.getElementById('m1224670822579').src;top.win.document.body.appendChild(image);}else break;void(0);
                          See ... i have an alert box ....i have to press OK until the next page loaded into the IFrame. Here i am unable to track the loading status of the IFrame .....
                          This is my problem ... ;)

                          Comment

                          • acoder
                            Recognized Expert MVP
                            • Nov 2006
                            • 16032

                            #14
                            Why can't you add an onload, e.g.
                            Code:
                            window.frames['orkutFrame'].onload= function() {...}
                            or use addEventListene r/attachEvent if you already have an onload.

                            Another alternative is to check periodically for the existence of the document using the technique in an earlier thread of yours - Accessing elements of an iframe.

                            Comment

                            • rnd me
                              Recognized Expert Contributor
                              • Jun 2007
                              • 427

                              #15
                              Originally posted by dmjpro
                              The Ajax function is taken care by Orkut itself ...i can't interfere the code ...I think without touching it's Ajax call back function i can't track the status OK.
                              why can;t you change orkut's code? you said it was running the same domain as you are. i clobber this's site vBulletin code in my greasmonkey scripts...

                              simple copy thier function, modify it, and load it with your script. do it before onload, and use window["globalName "] style syntax to over-rule the existing code.

                              Comment

                              Working...