There is a simple HTML page, named say abc.html. Now abc.html has a button named say ‘click me’. This page, abc.html, also has an iframe, with an id say ‘myframe’.
Now what i want is that when the button, ‘click me’, is clicked an alert box should come up inside the iframe named ‘myframe’. How can i do this?
I have tried the following..
window.frames[0].contentWindow.alert("this is the iframe");
but this does not seem to work. Please let me knwo why does this not work and what could be an alternate solution.
ContentWindow is derived from document, not window.
What you will want to do is add the alert into a function on the iframe page, then use
document.getElementById('targetFrame').contentWindow.targetFunction();to call it, (using targetFunction as example). This answer may give you further information on techniques.