Recent Widgets


Register for DashboardWidgets

Recent Forums Posts

Partners


iCompositions

MacDesktops.net

RSS Showcase
RSS Comments
RSS Forums

This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. Posted in: Widget Development

iframes onload and readystate

Author Message
jaime



Joined: 27 Mar 2005
Posts: 9

Posted: Wed Sep 01, 2004 - 2:10 am    Post subject: Imported from The Dashboader Reply with quote

Hi all! ,

I am trying to know when a new page is completely loaded in an iframe but neither onload event or readyState property seems to work properly inside the gadget. Can anybody help me about this matter? I am going bananas!

Thanks!
View user's profile Send private message Visit poster's website Widgets
Chris



Joined: 27 Jan 2005
Posts: 344
Location: Durham, UK

Posted: Wed Sep 01, 2004 - 2:10 am    Post subject: Imported from The Dashboader Reply with quote

Is the page inside the iframe an external page, i.e. one you don't have control of?
View user's profile Send private message Send e-mail Visit poster's website AIM Address Widgets
jaime



Joined: 27 Mar 2005
Posts: 9

Posted: Wed Sep 01, 2004 - 2:10 am    Post subject: Imported from The Dashboader Reply with quote

Yes, that¥s right, so I can not include any javascript code into those pages to control it; and it is curious because when I load a html document from my hard disk the onload event is triggered, but not when it is a external one, or that is what it seems .
Thanks for answering Chris.
View user's profile Send private message Visit poster's website Widgets
Chris



Joined: 27 Jan 2005
Posts: 344
Location: Durham, UK

Posted: Wed Sep 01, 2004 - 2:10 am    Post subject: Imported from The Dashboader Reply with quote

You could cheat, y'know Wink

Basically, you can pull any data using XMLHttpRequest. Just chuck the responseText as the innerHTML of a div and you're away. You have access to readyState changes that way. Something like:


xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState==4) {
document.getElementById("some_div").innerHTML = xmlhttp.responseText;
}
}


Now - I wouldn't recommend doing the above, as it's a bit 'hacky' I suppose... It'll work though Wink

p.s. Jeremy - this site needs [code] tag support

Oh, and since I'm a curious person, I think I may play around with this problem when I get back on my mac. What are you using external pages in a gadget for, may I ask?
View user's profile Send private message Send e-mail Visit poster's website AIM Address Widgets
jaime



Joined: 27 Mar 2005
Posts: 9

Posted: Wed Sep 01, 2004 - 2:10 am    Post subject: Imported from The Dashboader Reply with quote

That¥s great, thanks a lot Chris! I will try it!

> What are you using external pages in a gadget for, may I ask?

I am loading external pages in my gadget because I prefer not to launch Safari keeping all in the same interface and taking advance of Web Kit.

P.S.: I agree with Chris, we need a [code] tag support Wink
View user's profile Send private message Visit poster's website Widgets
jaime



Joined: 27 Mar 2005
Posts: 9

Posted: Wed Sep 01, 2004 - 2:10 am    Post subject: Imported from The Dashboader Reply with quote

I have been reading about the ìhackî Chris gave to me to pull data in, and I guess that this trick is only good if the document returned is XML , am I right?
View user's profile Send private message Visit poster's website Widgets
Chris



Joined: 27 Jan 2005
Posts: 344
Location: Durham, UK

Posted: Wed Sep 01, 2004 - 2:10 am    Post subject: Imported from The Dashboader Reply with quote

Well, not on the dev. stuff I've been using. Safari 1.3 and 2 and the dahboard. It's how I made a dictionary gadget that showed the results in the gadget - it pulled the whole page in and checked for the relevant bit...

The reason I didn't recommend it is because it may change at any point. For example, Moz doesn't allow you to do this (well, that's a bad example, because Moz doesn't seem to allow you to pull any data off of external domains......).

Try it and see if it works....
View user's profile Send private message Send e-mail Visit poster's website AIM Address Widgets
jaime



Joined: 27 Mar 2005
Posts: 9

Posted: Wed Sep 01, 2004 - 2:10 am    Post subject: Imported from The Dashboader Reply with quote

Wow, It works Chris, It is amazing! I read the XMLHttpRequest object article from the Developer Connection and they said: " It is essential that the data returned from the server be sent with a Content-Type set to text/xml. Content that is sent as text/plain or text/html is not accepted by the instance of the request object."

Thanks a lot for your time and trick!
View user's profile Send private message Visit poster's website Widgets
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.

 
Powered by phpBB © 2001, 2002 phpBB Group