PDA

View Full Version : Targeting a div in the parent window with a floating IFRAME



kasper48
01-11-2007, 06:23 PM
Hi There,

I'm using a script on my page that pops up a floating window. The window is a div tag with a nested iframe, the IFRAME content is loaded with an SRC....

Inside that window I am sometimes using AJAX calls to send info and forms that I want to have updated inside another DIV tag on the main page. I have tried using all kinds of 'parent.divid' combos in the target field of my AJAX function, but nothing works.

My Question: How do I identify an element that is outside the floating IFRAME in the Javascript function call?

I hope I haven't asked a really obvious question... I've been searching these forums and the rest of the net to no avail.

Cheers,

Greg.

jscheuer1
01-13-2007, 06:26 PM
If you are running a script inside an iframe that has had its content altered via Ajax, that script may not even be properly initialized. If that isn't an issue, the Ajax loaded content will act exactly as if it were hard coded onto the page that is displaying in an iframe. The easiest way to pick up an element in the parent window is to assign it as a global variable on the parent page:


var var_name=document.getElementById('myElementId');

and then to access it from the child page as:


parent.var_name

You can even go straight to:


parent.document.getElementById('myElementId')

kasper48
01-14-2007, 02:32 AM
Hi John,

The content has been loaded in a page altered by ajax.... any suggestions as to how to make sure its initialized properly?

Greg.

jscheuer1
01-14-2007, 03:04 AM
Hi John,

The content has been loaded in a page altered by ajax.... any suggestions as to how to make sure its initialized properly?

Greg.

I'd have to see it to really tell. As I implied, this may or may not be an issue, it depends upon what type of content it is and what if any type(s) of scripts it deals with and, if any - where those scripts are. Can you supply a link to your page?

kasper48
01-15-2007, 02:01 PM
Hi John,

I sent a link to the page to your email... I'm starting to do my reading on the DOM and setting variables.... this is where the solution lies most likely, no?

Greg.

jscheuer1
01-15-2007, 05:06 PM
OK, I see the floating iframe. I don't see content being loaded into that iframe via Ajax, what do I need to do to see that? I may just of missed it.

kasper48
01-15-2007, 06:11 PM
So when the window is open labeled 'define your course' when you type in codes such as 'P' then 'O' it will load up content (links) with some pretty standard autocomplete jazz.

Those links are the ones that I am trying to target the response of, back to the main parent page. Right now I have the response coming right into the window (it should load 'POLI 101 // //' or whichever course code you click) below the link itself...

hope this is coherent :)

Greg.

jscheuer1
01-15-2007, 06:59 PM
How do I get to that window? Anyways, if it is coming into the window itself, it should just about as easily be able to go to the parent window.

kasper48
01-15-2007, 08:59 PM
I solved the problem by getting rid of the IFRAME completely...

It was loading the contents with an SRC and I guess that meant I lost the stuff stored in the DOM?

I'm self taught and feeling my way through this.

Thanks for keeping me in the right direction.

Greg