Please refer this code:
Here i have the source of iframe is a html page which is inside the progect directory.
Default.htm
<form id="form1">
<div>
<iframe id="iFrame1" src="HTMLPage.htm"></iframe>
</div>
</form>
HtmlPage.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<form id="htmlform" action="http://w3schools.com/" method="post">
This is simple Html File
</form>
</body>
</html>
To find the action of form inside the iframe
Using JavaScript:
<script type="text/javascript">
window.onload = function () {
var frame = document.getElementById("iFrame1");
var action = frame.contentDocument.getElementById('htmlform').action
alert('Action of the form is: ' + action);
}
</script>
Using jQuery:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$("#iFrame1").load(function () {
alert('Action of the form is: ' + $(this).contents().find("form").attr('action'))
});
});
</script>