Paulo Roberto Rosa
Paulo Roberto Rosa

Reputation: 3295

How to use jQuery commands on the parent document inside a iFrame?

Info: I've read a lot of questions about accessing and such so, but i've not found anything about the inverse that is: Inside the access the parent document to change, and bind some elements from the parent document.

Problem: I dont know how to do that.

What i've tried:

1st try:

function ajax(){
  $(document.parentNode).contents().find("#ajaxLoading").show();
  document.parentNode.contentWindow.$('#mainFrame').load(function(){
    $(document.parentNode).contents().find('#ajaxLoading').hide();
    $(document.parentNode).contents().find('#pnlContentHeader').removeClass('front');
  });
}

2nd try:

function ajax(){
  document.parentNode.$("#ajaxLoading").show();
  document.parentNode.$('#mainFrame').load(function(){
    document.parentNode.$('#ajaxLoading').hide();
    document.parentNode.$('#pnlContentHeader').removeClass('front');
  });
}

3rd try:

function ajax(){
  document.parentNode.find("#ajaxLoading").show();
  document.parentNode.find('#mainFrame').load(function(){
    document.parentNode.find('#ajaxLoading').hide();
    document.parentNode.find('#pnlContentHeader').removeClass('front');
  });
}

I need some help with that, i dont really know what i'm doing...

Upvotes: 0

Views: 166

Answers (1)

sjkm
sjkm

Reputation: 3937

This should work using window.parent.document:

$(window.parent.document).find("#ajaxLoading").show();

Upvotes: 2

Related Questions