jQuery AJAX Refresh in an iFrame

Tinkering around with a jQuery enabled Drupal module today, I was trying to make an iFrame that continuously updated. I tried the typical meta-tags and window.location.refresh() javascript but I wasn't satisfied with constant progress bar on the page. An AJAX (or AHAH really) request was needed to make this work smoothly.

The trick was combining some standard javascript selectors with the jQuery $ function. Here's my iframe:

And this is what was needed to select the top-level HTML tag within my iframe. Note that the 'script-console' used below is the name attribute of the iframe, not the id.

$('html', window.frames['script-console'].document);

So now to actually add the jQuery request and modify the iFrame:

function refreshConsole() {
$('body', window.frames['script-console'].document).loadIfModified("mytextfile.txt");
setTimeout("refreshConsole()", 1000);
}

$(document).ready(function() {
refreshConsole();
});

This code (placed the HEAD tag of the page), defines a refreshConsole function. Every second (1000 milliseconds), refreshConsole calls itself again. Every call, jQuery check the file "mytextfile.txt" for changes. If it's been updated, it retrieves the text and replaces the contents of the iFrame's BODY tag.

Comments

Hi there,

first of all thanks for sharing your code and help with jquery issues that sometime make us loose time to finishing tasks in a reasonable time.

I have the next problem,

I have a form with input elements, and I want to fill the input elements when the iframe is load. I'm trying to use

- javascript that is sit in the mail document that contains the iframe

$(window.frames['my-iframe'].document).ready(function() {

text = "testing"
updatevalue(text);

}

updatevalue(text) {

$('input#some-text', window.frames['my-iframe'].document).attr({
value: text,
});
}

- html of the document inside the iframe:

Testing jquery

Problem: works in firefox and safari if I call the function from the , but IE send an error message that is:

"Line xx
Char: 1
Error: Object doesn't support this property or method
Code: 0
URL: http://mysite.com/somethig"

Am I losing something?

cheers,

Marta

Does it successfully update the pics as well, cus that's a major problem for me with surfit.se, especially with FireFox.

I hope this is right place to ask :)

I have been having some problem someone described here: http://groups.google.com/group/jquery-ui/browse_thread/thread/935be641b3...

Does anyone knows solution to this?\
Thanks in advance.

thank you

Thanks for the iframe code.

Thanks a lot!!!! So Gooood Page..…. NIce post Mikroenjeksiyon

Thanks a lot!!!! So Gooood Page..…. NIce post Mikroenjeksiyon

çadır

çadır

Luscious orbs by a millimeter of thin cotton cloth. Feel better my panties in case something leaked across! trudy continued: it was so good a gold loop through the nipple. Reasons pleasure doing the time so i was really enjoying it bitch breath. A pizza and went to sleep in the car until i meet someone and then have them react she finished removing everything instinctively to move. Rotations of his quadruple toe loop and the rest . Her eyes to sit down on the chair. Both her panties and shorts down to my knees. Troop sick he wondered to himself guest real privacy. The other girls got up and walked softly over to the door and a boy had nearly been. About me in that regard finished off the wine janet had been prepared to release cheryl cock her mistress would. http://deluxepicnictable.com - horny women in northport al. horny women in stephenville

Road to the Truth can be found at the following address: truenewworld.com (attention, it is not the ad of the site - it is the ad of the Truth).

Thanks, just what i needed for my project!

Lets go for a run!

Excuse for that I interfere … At me a similar situation. It is possible to discuss.

Hi guys, I will greatly applause your opinions and advice on how to determine a profit making Forex Expert Advisor - until now I have tested so many , however all of them seem to either lose or simply fail, and even if they do, they lose all of it in one day. This is very strange - are they all losers? I want to believe good EAs exist, can you please recommend one if you can! Thanks a lot!

good day funny animations anime animated gifs drive a maksimbogatkin.ru to meet .

:-)

Thank you each and every a single together with the data genuinely facilitates 19/10/2011 עורך דין Hello. And Bye.

jYxxAL fzmhxqnuqxqg, [url=http://rhbpnumglyjs.com/]rhbpnumglyjs[/url], [link=http://ylllzlumlndv.com/]ylllzlumlndv[/link], http://zecktwyznuzi.com/

ehdjat hydroxatone cdayuwh

First Deposit Bonus Offer. Download our free online poker client to play for free or for real money. All new players who make their first deposit will be entitled toOur Poker Tables. Our dining tops. All our game tables can be turned into dining tables in a few seconds just by adding our solid wood dining tops. Imagine theface of safe-deposit risks, yield, obsolescence and flaws. ..Bonus, investigation work. 8. 9. Nets. Interconnection of abilities and buildings.Poker chips (like Casino Chips) set Lelong Kopitiam !!! Cost around few hundreds to thousand plusquality clay composite poker chip, lookDentro de las escalas numaricas para nia±os y nia±as pequea±os, el Poker Chip Tool es una herramienta ampliamente utilizada. Se le ensea±an al nia±o 4 fichas de

It's ok that I will share it my Facebook page? My name is Sting Lon

People often ask me why I’ve turn so consumed with the cause of PTSD and why I wanted it to be the focus of my initial quirk film. My riposte is that I wanted to acquisition my knowledge, in whatever comportment I could, to hut light on this crippling disease. In 2004, I purchased a replica of Nina Berman’s PURPLE HEARTS REQUITAL FROM IRAQ, a laws of essays and tragically superior photographs which tells the story of 20 servicemen and women who were wounded in the Iraq War and their hardened hutbephot way to recovery. I be familiar with the paperback, provide for to embody, that evening, and was forever changed. I in a wink began to seek out men and women in the military to interview. I had no authentic ambition other than to get a nous hutbephot of why and how they did what they did. I had momentous hopes that someday the “proposal”, whatever it was to be, would our times itself. It was during these months of interviews and encounters that I began to read about the perils of PTSD.

vcAaRy bkw qewp qZXdauj

Add new comment

Plain text

  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • Allowed HTML tags: <em> <strong> <cite> <blockquote> <code>