I have iframe with with form elements such as input, select textarea etc. I need to get whole iframe content with entered values to those elements. In IE 7,8 it work fine, but in FF I'm getting empty or default values instead.
Here is code snippets:
Iframe content
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<div id="content">
<input name="fn" type="text" id="fn"/>
<select name="states">
<option val=""></option>
<option val="ca">CA</option>
<option val="co">CO</option>
<option val="ce">CE</option>
<option val="cI">CI</option>
</select>
</div>
</body>
</html>
Javascript inside the parent page
function getContentFromIframe(iFrameName){
var myIFrame = document.getElementById(iFrameName);
var content = myIFrame.contentWindow.document.body.innerHTML;
}
//calling function for example on button click
alert(getContentFromIframe('frame1'));
I entered value in input and chose something in select and ran script above. In IE I'm getting content with entered values, but ff and other browsers returns only html as it was loaded, although I can retrieve values separately for example with jquery
$('#frame1').contents().find('#fn').val()
I really stack with this problem. Please help me. Thanks.
May be there is any other way to get this content without using innerHTML?