i am developing an app in js. i need to read and parse html contained in dynamically changing iframe src. iframe src always points to a wikipedia article. i tried reading simple html source with methods described in other solutions here n it worked:
How to get iFrame src content using javascript?
How to get the body's content of an iframe in Javascript?
but i am not able to read any wikipedia article in the frame source! help me out please!! thnk... below is my code:
<html>
<head>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
function showIt(){
alert($("#ifr").contents().find("body").html());
}
</script>
</head>
<body>
<a href="#" onclick="showIt()">Click here</a><br />
<iframe id="ifr" name="ifr" src="http://en.wikipedia.org/wiki/Bus" height="100%" width="100%"></iframe>
</body>
<script type="text/javascript">
var iframeWindow = top.frames['ifr'];
iframeWindow.onload=function(){alert('here');iframeContent=iframeWindow.document.body.innerHTML;
};
</script>
</html>
my question is different from Query Wikipedia's API using AJAX (XMLHttpRequest)
I know this wikimedia's API and i also know how to use it! but it doesnt serve my purpose. this API returns article in plain text format encoded in JSON.
But what i want is articles formatted in HTML! I know how to do it in PHP. But i wanna do it in JS! Just help me with reading the HTML source of an iframe containing WP article. I know how to manipulate the content then.
OK.I read the "Same origin policy". It cant be done :P . CLOSED.