By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,831 Members | 1,031 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,831 IT Pros & Developers. It's quick & easy.

Track the response status of a IFrame

dmjpro
100+
P: 2,476
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. .. ?
Oct 22 '08 #1
Share this Question
Share on Google+
24 Replies


acoder
Expert Mod 15k+
P: 16,027
Use the onload event.
Oct 22 '08 #2

dmjpro
100+
P: 2,476
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 ?
Oct 22 '08 #3

acoder
Expert Mod 15k+
P: 16,027
Post the code that you're testing with.
Oct 22 '08 #4

gits
Expert Mod 5K+
P: 5,234
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
Oct 22 '08 #5

dmjpro
100+
P: 2,476
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 ... ????
Oct 23 '08 #6

acoder
Expert Mod 15k+
P: 16,027
Is the site loaded into the iframe from the same domain?
Oct 23 '08 #7

rnd me
Expert 100+
P: 427
if the iframe is in a different domain than the html page pointing to/containing your script, then no.
Oct 23 '08 #8

dmjpro
100+
P: 2,476
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 .....
Oct 23 '08 #9

acoder
Expert Mod 15k+
P: 16,027
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?
Oct 23 '08 #10

dmjpro
100+
P: 2,476
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 ... ;)
Oct 23 '08 #11

acoder
Expert Mod 15k+
P: 16,027
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.
Oct 23 '08 #12

dmjpro
100+
P: 2,476
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 ......


Expand|Select|Wrap|Line Numbers
  1. 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 ... ;)
Oct 23 '08 #13

acoder
Expert Mod 15k+
P: 16,027
Why can't you add an onload, e.g.
Expand|Select|Wrap|Line Numbers
  1. window.frames['orkutFrame'].onload= function() {...}
or use addEventListener/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.
Oct 23 '08 #14

rnd me
Expert 100+
P: 427
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.
Oct 23 '08 #15

dmjpro
100+
P: 2,476
Why can't you add an onload, e.g.
Expand|Select|Wrap|Line Numbers
  1. window.frames['orkutFrame'].onload= function() {...}
or use addEventListener/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.
Acoder one thing clarify me ...that if a page gets loaded using Ajax then OnLoad events gets fired or not ..i think not .....and here the IFrame gets loaded using Ajax.
And did mean 'Periodically' ..... should i use 'interval'?
Oct 24 '08 #16

dmjpro
100+
P: 2,476
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.
I am running a code from Orkut not from my domain. If i could know that which page gets called to load the IFrame then there would no problem ..i could have written my Ajax function any way i think it's not possible to track the status of a page when it gets loaded using AJax. :(
Oct 24 '08 #17

acoder
Expert Mod 15k+
P: 16,027
Acoder one thing clarify me ...that if a page gets loaded using Ajax then OnLoad events gets fired or not ..i think not .....and here the IFrame gets loaded using Ajax.
If it's getting loaded, then why not?
And did mean 'Periodically' ..... should i use 'interval'?
Yes, setInterval.
Oct 24 '08 #18

acoder
Expert Mod 15k+
P: 16,027
I am running a code from Orkut not from my domain. If i could know that which page gets called to load the IFrame then there would no problem ..i could have written my Ajax function any way i think it's not possible to track the status of a page when it gets loaded using AJax. :(
Why can't you check the source code? Use firebug to make things easier.
Oct 24 '08 #19

dmjpro
100+
P: 2,476
Why can't you check the source code? Use firebug to make things easier.
Did you ever check out the source code of Orkut ...those are generated code ...
Actually Google uses GWT for better web development with Ajax.
So it's not easier to understand their source code ...what do you mean by FireBug?


And one more thing ..... setInterval is stupid solution, it also struck my mind ......but ... :(
Oct 24 '08 #20

acoder
Expert Mod 15k+
P: 16,027
You can see the generated source code using the Web Developer/Firebug Firefox extensions. Seek and you shall find...

PS. is this what you're working on?
Oct 24 '08 #21

dmjpro
100+
P: 2,476
You can see the generated source code using the Web Developer/Firebug Firefox extensions. Seek and you shall find...

PS. is this what you're working on?
No no i am not in this ..... just i am simply doing funs with Orkut ......


Hey Acoder what a fantastic thing ....the Firebug is interesting i think now it would be easier to solve ;)
Oct 24 '08 #22

acoder
Expert Mod 15k+
P: 16,027
No no i am not in this ..... just i am simply doing funs with Orkut
If you are, then wouldn't you be writing an app for it? Orkut docs
Hey Acoder what a fantastic thing ....the Firebug is interesting i think now it would be easier to solve ;)
Yes, I think we can agree on that one :)
Oct 24 '08 #23

dmjpro
100+
P: 2,476
If you are, then wouldn't you be writing an app for it? Orkut docs
Yes, I think we can agree on that one :)
Ok thanks ....!!!

But one problem is there ... how to track the actual code when an event gets fired ..is that possible to track using FireBug.
I can track the element in the FireBug...i mean i can do inspection in FireBug ..but can not track the actual code of an event event handler .. :(
Oct 24 '08 #24

rnd me
Expert 100+
P: 427
Ok thanks ....!!!

I can track the element in the FireBug...i mean i can do inspection in FireBug ..but can not track the actual code of an event event handler .. :(
sure you can. try one of the two DOM tabs (full or element).
Oct 24 '08 #25

Post your reply

Sign in to post your reply or Sign up for a free account.