Click here to Skip to main content
15,887,436 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have a html page which contains the nested iframe . I want to access the content of the child page or the value of input inside that using javascript .
Posted
Comments
Zoltán Zörgő 18-Dec-12 8:58am    
Due to the default "same origin policy", you can do this ONLY if the outer and the inner content is coming from the same domain. You can only bypass this if you set some metadata, but for that you need to have access to the inner source on it's server.
[no name] 18-Dec-12 8:59am    
HI,

Yes you can. Tell me what is the iframe structure of your side?
vaibhavraidwivedi 18-Dec-12 11:16am    
<Html><head></head>
<body>
<form id=frm1>
<iframe src="http://www.abc.com">
<iframe src="https://www.abc.com"></iframe>
</iframe>
</form>
</body>
</html>

It structured like that ........On the child i frame there is a text box which contains the user name i want to access that ........Is it possible , i tried it here but its not working......and also i need to give the src of the iframe ........is it possible that we can access the iframe src using js

 
Share this answer
 
Comments
Abhishek Pant 19-Dec-12 9:16am    
accepted and downvoted??
Hi,

you can assign your iframe some ids and use that id to access the iframe control and can able to get the elements inside the iframe.

XML
<script type="text/javascript">
        function parent_function() {
            alert('parent');
        }
        function doit() {
            parent_function();
            document.getElementsByTagName('iframe')[0].contentWindow.iframe1_function();
            document.getElementsByTagName('iframe')[0].contentWindow.document.getElementsByTagName('iframe')[0].contentWindow.iframe2_function();
        }
    </script>



This may help you for understanding.
The above mentioned links are also useful. Please go through them.

Thanks
 
Share this answer
 
Comments
[no name] 19-Dec-12 9:14am    
Please upvote to 5 stars. otherwise it will be considered as downvoted.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900