Kees C. Bakker
Kees C. Bakker

Reputation: 33431

How to get the frameset from a frame window?

Consider the following code:

function hide(aFrame) {
    var frameset = aFrame.frameset; //<-- this doesn't work
    $(frameset).attr('cols', '0,*');
}

//hide parent frame
hide(window.parent);

//hide current frame
hide(window);

I have a function that takes a frame and I would like to hide it by changing the cols of its frameset. jQuery may be used to answer the question (but a pure JavaScript solution is okay as well).

Upvotes: 2

Views: 252

Answers (1)

Kees C. Bakker
Kees C. Bakker

Reputation: 33431

The trick seems to be querying the parent document:

function hide(aFrame) {
    var frameset = aFrame.parent.document.getElementsByTagName('frameset');
    $(frameset).attr('cols', '0,*');
}

Upvotes: 1

Related Questions