views:

84

answers:

2

Hi,

Hoping someone can assist but I am trying to access a div id="mnuGrp" that resides inside a child iframe(id="iframe2) from the parent window within the document.ready() section but unsure how to access this child div in the parent inorder to apply fadein and fadeout calls.

Want to be used within the following call:

$(' ???? ').click(function(){ etc

where "????" is my means to access the child div within the iframe.

Any help would be appreciated.

Thanks.

+2  A: 

You can access the div in this way: window.frames[framename].document.getElementById("mnuGrp")

Kangkan
thanks Kangkan but how would I use this inside a document.ready call, such as $(' ???? ').click(function(){ etc
tonsils
I imagine $(window.frames[framename]).find('#mnuGrp') would work
colinmarc
jQuery: for people who don't understand JavaScript.
Adrian
Yea.. because the Javascript language is that well written everyone needs to understand there silly mistakes and choose not to use a mask for the language :/
RobertPitt
`getElementById`, not `getElementByID`.
Tim Down
@Tim, sorry for the typo.
Kangkan
Kangkan: No need to apologise. I've edited the answer to correct it.
Tim Down
+3  A: 

Since you're asking in a jQuery context specifically:

$(document).ready( function(){
    $('#iframe2').contents().find('div#mnuGrp').fadeIn('slow');
    // or whichever effect you prefer
});

Note that you will likely be constrained by the Same Origin Policy with respect to the main page and the frame source.

Ken Redler
The Origin policy would mainly be X-Frames where your accessing content on a frame that's not abiding to your domain.
RobertPitt
Thanks all for your responses and a special thanks to Ken.
tonsils