[ACCEPTED]-Triggering an event handler on an element inside iframe from parent frame-event-handling
Accepted answer
Here is how you can do it.
document.getElementById('ifrmMsg').contentWindow.$('a:first').trigger('click');
- Demo: http://jsbin.com/aYijiLe/2
- Parent: http://jsbin.com/aYijiLe/2/edit
- iFrame: http://jsbin.com/IrogeBi/1/edit
You can also use 4 postMessage()
for this purpose. It will work cross-domain as well. However 3 JS inside the iframe must listen to the 2 message
event, i.e. you need to control the source 1 of the iframe.
- Demo: http://jsbin.com/ILAsEmE/1
- Parent: http://jsbin.com/ILAsEmE/1/edit
- iframe: http://jsbin.com/uZEQuTa/2/edit
Just place onload() event inside the iframe 1 tag.
<iframe src="http://myURL.com" onload="myFunction()">
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.