View Full Version : simple iframe help

02-06-2011, 04:29 AM
how would you get this code to work from an iframe to the parent page?

<img src="Picture.png" onclick="My Code"/>

I'm Looking to get the 'onclick="My Code"' to apply for the parent page

sorry, i really hope this is specific enough, thanx

02-06-2011, 04:42 AM
I believe you can use this:

Note: iframes bring up security issues, but if both pages are from the same domain it should help.

02-06-2011, 04:50 AM
sweet, ill give it a try

02-06-2011, 04:55 AM
hmmm... actually i used this in the iframe code and it dosn't seem to be working:

<img src="Picture.png" onclick="window.parent.Appear('VideoFolder');"/>

know what's going on?

02-06-2011, 07:28 AM
I'm not sure. I'd suggest starting simple, with a dummy function like makealert() in which there is only the code alert('Hello World');. Once that works, see if you can combine it.

02-06-2011, 07:50 PM
alright, i'v already tried that and i don't think i told you enough on the first run. what this script does is simply make things disappear and appear by id, so i have dialogs by specific id's that disappear/appear by a special button located in an iframe, so here is the script making them disappear and appear:

function Appear(itemID){
// Toggle visibility between hidden and visible
if ((document.getElementById(itemID).style.visibility == 'hidden'))
document.getElementById(itemID).style.visibility = 'visible';
} else {
document.getElementById(itemID).style.visibility = 'hidden';

so i want each button to be able to make a different object appear/disappear. and if i made a different section of the script for each dialog it would be massive, so i'm trying to find an easy way around. got any ideas?