Reputation: 670
<html><head>
<title>Welcome</title>
<style type="text/css"></style></head>
<frameset border="false" frameborder="O" framespacing="0" rows="0,*" cols="*">
<frame marginwidth="0" marginheight="0" name="frame_rsafp" src="rsa_flash_cookie.html" noresize="true" scrolling="no">
<frameset border="false" frameborder="O" framespacing="0" rows="*,30" cols="*">
<frame marginwidth="0" marginheight="0" name="login_page" noresize="true" scrolling="yes">
#document
<html>
<form name="frmLogin" action="entry" class="login" method="post" target="_top" autocomplete="off">
<span class="passfield">
<input type="text" name="LoginUserId" onkeypress="return fSubmit(event);" value="" class="ipassword">
</span>
</form>
</html>
<frame marginwidth="0" marginheight="0" name="footer" src="footer.html" noresize="true" scrolling="no">
</frameset>
</frameset>
</html>
For above html code I want to set value to text field "LoginUserId".
I tried
document.getElementsByName("LoginUserId")[0].value = "MyValue";
but it returns the error Cannot set property 'value' of undefined.
I can only get elements upto "login_page" and count of child elements of "login_page" returns 0.
var ele = document.getElementsByName("login_page")[0].childNodes;
alert(ele.length);
How can I get elements of this nested html document?
Upvotes: 0
Views: 2901
Reputation: 1335
Try this
var loginBox = document.getElementById('login_page');
var values = loginBox.getElementsByName("LoginUserId")[0].value;
Upvotes: 1
Reputation: 10562
You need to get the iframe first:
var iframe = document.getElementById('iframeId');
var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
and then you can work on that document
Upvotes: 0
Reputation: 77482
Try this
var iframe = document.getElementsByName("login_page")[0];
var ele = iframe.contentDocument || iframe.contentWindow.document;
Upvotes: 1