Skip to main content
Home
Nate Lampton - quicksketch.org
  • Blog
  • Bio
  • Contact

jQuery AJAX Refresh in an iFrame

Posted May 07, 2007 | 11:38 pm MDT

jquery
javascript

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:

Comments

Hi there, first of all

Submitted by Marta (not verified) on Nov 26, 2007 | 04:48 pm MST

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

Submitted by Guest (not verified) on Dec 02, 2007 | 09:27 am MST

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

Submitted by Kacper (not verified) on Feb 19, 2008 | 02:08 am MST

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/935be641b3d38c9e

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

thank you

Submitted by komik (not verified) on Mar 09, 2008 | 06:35 am MDT

thank you

Thanks for the iframe code.

Submitted by RCA (not verified) on Mar 30, 2008 | 08:35 pm MDT

Thanks for the iframe code.

Super

Submitted by Gert-Jan (not verified) on Jul 09, 2011 | 09:09 am MDT

Thanks, just what i needed for my project!