Javascript get Iframe contents -


i'm trying content of iframe in javascript alert but, 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 appreciated regards

edit:

i'm trying contents of iframe because i'm using adf.ly api "http://api.adf.ly/api.php?key=c02fe2b360ee4b566a4f1e14d84b279b&uid=3141484&advert_type=banner&domain=adf.ly&url=http://somewebsite.com" api respond blank page shortend url want use shortened url directly in site script

i guess main (parent) page on domain. in case access iframe content forbidden due cross-domain restrictions. if don't have control on inner page (api.adf.ly/api.php) can't handle on client-side code on page.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -