Tuesday, March 13, 2007

Iframes and jQuery - Working with an iframe's parent

As I stated in my last post about iframe's and jQuery, the load event was only fired once in Internet Explorer, so this may be a problem in some situations (for instance, when you go to a new page in the iframe (which is the only reason I can think of for using one instead of includes)). You can put the code into the iframe and work with the page that contains it instead. This actually may be more desirable as it is simpler and works in more browsers (Firefox, Internet Explorer, Opera 8.54+ tested)

$( function() {
   var p = parent;
   $("a").click( function() {
       p.$("#myinput").val("Anchor clicked: " + this.href);
       return false;


Anonymous said...

Hello Sam,

Was looking for another way to contact you but didn't find one. I am using your jquery-select code and was wondering how hard would it be for you to add a function to check for the existence of a value in the current list?

Take care,

Sam said...

$("#myselect").containsOption("val1") can be useed for this