Rahh
Rahh

Reputation: 109

Hide Div on iFrame (Within same domain)

Okay so i'm pretty much trying to load a section from my forum onto my main page within an iframe.

I know it's not possible to manipulate frames that don't come from your own domain; but my forums on the same site so it should be sweet. When it loads; the iframe opens up the whole forum up; so I just want to hide certain divs on the loaded iframe.

I'm really not sure how I should go upon doing this. I've tried many things like;

document.getElementById('page-header').style.display="none";

or

#page-header {
diplay: none;
}

But neither's seeming to work.

Any help would be great. (:

Upvotes: 1

Views: 1442

Answers (3)

Rahh
Rahh

Reputation: 109

Found an answer on googles, thought i'd post it incase anyone else runs into this issue.

    $(function(){
        var f=$('#FRAMESID')
        f.load(function(){ 
            f.contents().find('#DIV_ID').hide(); 
        })
    })

Upvotes: 1

Luca
Luca

Reputation: 9705

https://developer.mozilla.org/en/docs/Web/HTML/Element/iframe

you first need to access your iframe, e.g. like this (supposing that you only have one iframe on your page):

  window.frames[0].document.getElementById('page-header').style.display="none";

read the documentation and find the way that best suits your existing code to find your iframe, but the code above should get you started

Upvotes: 0

Jaydeep Pedhadiya
Jaydeep Pedhadiya

Reputation: 534

You can try this for Inner div of iframe.

$('#frame id').contents().find('#div Id').fadeIn('slow');

Upvotes: 0

Related Questions