How do you invoke javascript code in an iframe from parent page? Initially iFrame needs to be accessed using either document.getElementBy or window.frames. After that contentWindow property of iFrame gives the access for targetFunction
1 2 3 4 | document.getElementById('targetFrame').contentWindow.targetFunction(); // Accessing iframe this way may not work in latest versions chrome and firefox window.frames[0].frameElement.contentWindow.targetFunction(); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.