Saturday, March 6, 2010

Calling a Function in iframe

I mentioned how I call a function from iframe. Now I explain how I do the opposite, calling a function in iframe from the parent or main HTML.

After trying a few suggestions found using Google, I find this working for all the browers I use, viz., IE, Firefox, Safari and Chrome:

document.getElementById('framename').contentWindow.functioname(argument);

You can replace your own framename, functionname and argument.





Update: It will not work on Chrome if you are running in local host due to security reason. Upload to a web server and it will work.

No comments:

Post a Comment