How to access a element of a frame from other frame. For Ex:
Main.html:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</head>
<frameset rows="33%,33%,*">
<frame class="fra" src="frame1.html"/>
<frame class="fra" src="frame2.html"/>
</frameset>
</html>
frame1.html:
<html>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</HEAD>
<body>
<b><p id="para"> This is frame one.html </p></b>
</body>
</html>
frame2.html:
<html>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</HEAD>
<body>
<b><p id="para"> This is frame two.html </p></b>
<button id="but"> Get data </button>
<script>
$(document).ready(function(){
$("#but").click(function(){
alert(window.frames[0].document.getElementById('para'));
});
});
</script>
</body>
</html>
Once the button is clicked from frame2 then I need to get the data of "para" id element which is present in frame1. So, I tried to access the element as showed below. But it is not worked.
window.frames[0].document.getElementById('para')
It shows the error as:
Uncaught TypeError: Cannot read property 'document' of undefined
So, window.frames[0]
itself undefined
.Can any one help me to solve this?