Click to See Complete Forum and Search --> : calling the main window from an iframe


andyroo
09-22-2003, 02:01 AM
Hi, im pretty stuck here, for all i know this should be working.

i have a main window with the following function

function changeVis(thing){
if (thing.style.display == 'block')
{
thing.style.display = 'none';
}
else
{
thing.style.display = 'block';
}

to hide and display a table using CSS.

i can call the function fine, and it works, until i put it in an iframe i have on the page

im calling the function from the iframe with the following code

<a href="javascript:window.parent.changeVis(theObject)">

but i keep gettin errors saying theObject is undefined. I cant seem to get the function to break out of the iframe window. Ive tried every combination i can think of and still no go.

any thoughts?

Khalid Ali
09-22-2003, 05:39 AM
Thats not the syntax..you need to do it like this

parent.changeVis()
should have worked fine,
post the url to the page where you have this implemented

andyroo
09-22-2003, 10:57 AM
http://www.idsgn.org/andy/index.php

the iframe being under the portfolio section.
what im trying to do is have the table close when someone clicks on the link in the iframe

Khalid Ali
09-22-2003, 01:09 PM
I don't see the iframebeing loaded..however,targetting a function from the ifram will be like this

parent.functionName();

while from parent to iframe

parent.frameName.functionName()

andyroo
09-22-2003, 01:19 PM
thanks for the help here.

the iframe is loaded in a table that is displayed when you click the link "portfolio"

anyway, i changed the function on the parent frame to just an alert to see if it was actually passing the function, which worked.

on the index.php file the link on the portfolio button is

<a href="javascript:changeVis(portTable)">

this works fine.
when i put it in the iframe, and change it to
<a href="javascript:parent.changeVis(portTable)">

it says that 'portTable' is undefined. is it searching for 'portTable' within the iframe?

ive also tried using
<a href="javascript:window.top.changeVis(portTable)">

with the same result

thanks again

Khalid Ali
09-22-2003, 01:21 PM
yes it will search for portTable in the iframe document,if this portTable is ion the parent then you will need to say

parent.portTable

andyroo
09-22-2003, 01:23 PM
perfect!

Thanks!

Khalid Ali
09-22-2003, 01:32 PM
:D
Glad to be help...