Reputation: 18029
Im having a webpage with an iframe with form in it. I want to submit the form and get the result. How can i do it with jquery?
<iframe src ="html_intro.asp" width="100%" height="300">
<form action="submit.php">
<input type="text" name="name" />
</form>
</iframe>
Upvotes: 1
Views: 6750
Reputation: 382746
Try this:
$('#iframe_id').contents().find('form')[0].submit();
It is assumed that your are NOT hosting other domain in your iframe.
Upvotes: 1
Reputation: 1038930
If the iframe is hosted on a domain different than the parent domain you cannot manipulate it with javascript. To submit the form from within the iframe you could use the submit method:
$('#yourFormId').submit();
Upvotes: 0