PDA

View Full Version : Accessing DIVS from inside an IFRAME


Axium
11-25-2002, 08:56 PM
I have two IFRAMES embedded in a main document. I need to access divs to hide them from inside those iframes.

My hide function goes something like this in the parent window:

function hide(id) {

// dom check.. omitted
if (browserName == "NS") { document.layers[id].visibility = "hide"; }
else { document.all[id].style.visibility = "hidden"; }

}

How would you access that div from within the iframe? (I can just make a new function).

Thanks ahead of time.

Justin

glenngv
11-26-2002, 03:32 AM
you can call the function in the main window from the iframe.

in the iframe:

<input type="button" value="test" onclick="top.hide('testID')">

you may want to check if the page is loaded in the iframe or opened directly in the page.

<input type="button" value="test" onclick="if (top!=window && typeof top.hide=='function') top.hide('testID')">