Javascript get Iframe contents
I'm trying to get the content of iframe in a javascript alert but, the
alert appears empty
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<style>
iframe {height:200px; width:300px; border:1px solid #000}
</style>
<script>
var iframe = document.getElementById("myFrame");
var iframe_contents = iframe.contentDocument.body.innerHTML;
function newDoc() {
alert (document.getElementById('myFrame').innerHTML) ;
}
</script>
<body>
<iframe
src="http://api.adf.ly/api.php?key=c02fe2b360ee4b566a4f1e14d84b279b&uid=3141484&advert_type=banner&domain=adf.ly&url=http://somewebsite.com"
id="myFrame">
</iframe><br>
</br>
<img
src="http://www.giftworksconnect.com/wp-content/uploads/2012/10/download.png"
width="100" onclick="newDoc(); return false;" style=" cursor: pointer;"
border="0" id="adflink" />
</body>
</html>
any help would be appreciated Regards
No comments:
Post a Comment