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

Your name:

Reply:


Posted by Jonathan N. Little on 04/06/06 23:29

Chris Ianson wrote:
> "Jonathan N. Little" <lws4art@centralva.net> wrote in message
> news:44352ec4$0$3695$cb0e7fc6@news.centralva.net...
>
>> Since here has not event identified what Google Maps API function he is
>
> I'm curious - what is your native language Jonathan?
>
>> 1) What an IFRAME
>
> English?

My crime here was thoughts faster than fingers and then not proofing
before posting! Now in English:

Since he has not even identified what Google Maps API function he is
trying to call this is all speculation! Google Maps API seems to be
standard JavaScript. The API seems very straight forward where you
reference the map element on your document and they have built the API
as OOP where your call various object methods to control the map. What
is unclear is:

1) What in IFRAME
2) What function
3) Is the function his code or Googles
4) Is his code in the parent frame or the iframe or both
5) Some code...URL something.

Lastly I stand by my statement, that is how you reference an anonymous
parent frame function. Would be willing to assist if more info was
supplied. Really.

>
> With Google you can create functions and programs. We have one called
> 'walk' which calls a new htm file in the child frame.
>

Google is not a programing language, just some JavaScript where they
have made predefined objects to assist with interfacing with their map
program. So I can see no 'walk' method in any of Google Maps API so I am
assuming that this is your JavaScript function.

> Not disputing that and never have, the question was 'is there any other
> way'.
>

Not that I am aware of. One of the complications that arises with
frames, (framesets or using iframe the same problem exists). Since we
have no code here to look at I can only assume you have a problem with
your function. What does Firefox's JavaScript console say...great for
debugging JavaScript. Does the function 'walk' work without the iframe?
How about if you substitute a debug function to test?

function walk(param){
alert("walk called with param '" + param + "'");
}

Test calling function from top frame yourself:
Base page:

<html>
<head>
<title>Outside</title>
<script type="text/javascript">

function test(where){
alert('Hello from ' + where );
}
</script>
</head>
<body>
<a href="#" onclick="test('Top')">Test</a>
<iframe name="inner" src="insert.html"></iframe>
</body>
</html>

Iframe insert:

html>
<head>
</head>
<body>
<h2>Inner</h2>
<a href="#" onclick="parent.test('Inside')">Test</a>
</body>
</html>

But when I see your reference such as "javascript:parent.walk(3)" then
the manner of *how* your are calling the function may be the problem. I
wrote: Are you calling the function via:

<a href="javascript:parent.walk(3)...

if you are, this may be your problem. Do not put

"javascript:somefunction()"

in a href attribute, put it on the event handler, i.e.,

onclick="somefunction()"



--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация