Tuesday, January 5, 2010

Calling Daddy?

Start to scratch my head what to write today. I thought I was more affluent than this. Anyway, this is a simple trick to call a javascript function from an iframe:


"javascript:parent.myfunction()"


This is useful when you are using iframe and you need to call a function that is running on your main HTML or the "daddy" HTML. I call the iframe the "child".

Why do you need to call "Daddy" and not run javascript directly from iframe?

If you need to control a DIV layer from an iframe, you need this. One cannot control a layer such as visibility from iframe (child) unless the function is run from the "daddy" HTML.

If you are able to make "daddy" stuff disappear from "child" HTML, let me know. But I find building a function in the "daddy" HTML and calling the function from "child" HTML more convenient.

Hope this helps!

No comments:

Post a Comment