How do call a function from inside an iframe?

P

Paul

HI! I need to call a function that is located in the parent. I need it so
that it calls when the child page in the iframe loads.

Would it be better to use an onload event in the body? if so how do I call
it from the child page?
 
D

Dr Clue

Paul said:
HI! I need to call a function that is located in the parent. I need it so
that it calls when the child page in the iframe loads.

Would it be better to use an onload event in the body? if so how do I call
it from the child page?


This should work just fine.

<iframe onload="self.foo()">

</iframe>



--
--.
--=<> Dr. Clue (A.K.A. Ian A. Storms) <>=-- C++,HTML, CSS,Javascript
--=<> http://resume.drclue.net <>=-- AJAX, SOAP, XML, HTTP
--=<> http://www.drclue.net <>=-- SERVLETS,TCP/IP, SQL
--.
 
J

Jon Spivey

Hi,
Onload fires when the whole page (including iframes) has loaded. You'd put
the function call in the body of the parent page, eg
<body onload="someFunction();">
 
P

Paul

HI! Thanks, I will try it. :)

Paul

Jon Spivey said:
Hi,
Onload fires when the whole page (including iframes) has loaded. You'd put
the function call in the body of the parent page, eg
<body onload="someFunction();">
 
P

Paul

HI! I want to simulate resizing the parent page page by using this function.

<script language="JavaScript">
function firefoxautofix(x,y,){
parent.window.resizeBy(-1,-1)
parent.window.resizeBy(+1,+1)
}
</script>

Should this function be in the head or the body?

I want to get around a small bug in firefox that does not seem to resize (
after a iframe resize script is executed) the body unless the user refreshes
the page or resizes the browser manually from left to right. So I figure
that I would try to simulate a manual resize with this script.

Would I just call it like so.

<body onload="firefoxautofix();">
 
R

Ronx

Note that firefox has an option setting to disable scripts that resize
the browser - I believe this is the default setting.
In FireFox: Tools->Options->Web Features - Advanced button
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top