Reputation: 12631
I have below two html files in two different web applications. WebApp1(somedomain.com)
has PassValueIFrame.html
and WebApp2
has inputForm.html
. Here WebApp1 is secured and requires authentication
. In PassValueIFrame.html
i have an iframe which refers inputForm.html
. Also, i have one hidden field in PassValueIFrame.html
and am trying to retrieve its value in inputForm.html
but am not getting its value it alerts as 'Permission denied to access property 'document'
'. Am i doing any wrong here? Please help me. As WenbApp1
is secured, cannot we access PassValueIFrame.html
? if we cannot access then is there any way to access secured page contents?
<html>
<head>
<title>IFrame Example</title>
</head>
<body>
<input id="myInput" type="hidden" class="Language" value="English">
<iframe name="iframe" id="iframe_id" src="http://somedomain.com/inputForm.html" height="150" >
</iframe>
</body>
</html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script language="javascript">
$(document).ready(function() {
alert($("#myInput", window.parent.document).val());
});
</script>
<title>IFrame Child Example</title>
</head>
<body>
<h1> Iframeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee </h1>
</body>
Thanks!
Upvotes: 0
Views: 1675
Reputation: 1039578
You seem to be violating the same origin policy restriction. You cannot access the iframe contents if both the parent and the iframe are hosted on the same domain. So basically if you want this to work you will have to host PassValueIFrame.html
on http://somedomain.com
.
Upvotes: 1