Re: A Challenge: Call parent Javascript function from inside an iframe?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: A Challenge: Call parent Javascript function from inside an iframe?

From: Chris Ianson <notme@hotmail.com>
Date: Thu Apr 06 2006 - 16:37:39 CEST

"Marcello" <marcello.antolino@gmail.com> wrote in message
news:1144327408.574209.5060@v46g2000cwv.googlegroups.com...

> I've never used Google Maps API, so I don't know if you have access to
> code on the parent window. If you do, put a function over there that
> access the Google Maps one, and your function in the IFrame then access
> your function in the parent frame.

Yep we actually just tried something similar.

The parent page now declares a map function called "walk()".

The child page (iframe) should no longer make its own changes to the iframe
contents. When it wants to jump, it should make calls like
"javascript:parent.walk(3)"

[if you're unfamiliar with what is going on in the iframe from a previous
discussion here, there's an example at
http://www.cjse.pwp.blueyonder.co.uk/misc/A1master.htm]

The parent code will then update the map *and* update the iframe contents.
Simple.

Trouble is, it means that navigating in the iframe then relies on JS, which
rules out around 10% of people. Their loss sure, but still not ideal. We
are looking to keep the navigation as HTML.

> If that still doesn't work, try putting and invisible FRAME (not
> IFrame) in the parent window to do the same 'proxy function' approach.
> I had to do it once, in another problem. For some reason it was not
> working from parent to child <-> child to parent frames, but taking
> this proxy function approach solved the problem.

Have passed this on to the other designer and will keep fingers crossed!

> Also, are you passing 'objects' or functions as parameters in this
> call?

Only as above really.

Thanks for your constructive reply Marcello. You seem to have understood
what we are after. Cheers.
Received on Mon May 1 04:45:39 2006