...

View Full Version : Can I copy text content from <iframe> to variable ?



mr.python
03-14-2012, 12:59 PM
Hi world
I have this code in my page


<iframe name="ff1" src="http://playerplus.co.nu/ipp.php"

></iframe>
how i copy the result in this iframe to text or to some variable
but from iframe not direct from the URL "http://playerplus.co.nu/ipp.php"

mr.python
03-14-2012, 01:13 PM
Example
I want to extract the contents of this page programmatically not manually
http://playerplus.co.nu/test.php

devnull69
03-14-2012, 04:52 PM
Is the iframe src URL on the same domain and subdomain as the current page? If not, browser security will prevent Javascript from accessing cross domain content.

mr.python
03-14-2012, 05:07 PM
Is the iframe src URL on the same domain and subdomain as the current page? If not, browser security will prevent Javascript from accessing cross domain content.

my friend look to my example

http://playerplus.co.nu/test.php

I want to extract the contents of this iframe to variable by ( select all & copy) or by cloning or by any way . Now I don't play with "browser security"

2reikis
03-14-2012, 08:26 PM
This function assumes your iframe has an id if "myiframe".


function getContentsOfIframe()
{
var frameObj=document.getElementById("myiframe");
var frameDoc=(frameObj.contentWindow || frameObj.contentDocument);
if (frameDoc.document) frameDoc=frameDoc.document;
frameDoc.body.innerHTML = "hi";
alert(frameDoc.body.innerHTML)
}

so your html would have to be


<iframe src="http://playerplus.co.nu/ipp.php" id="myiframe">

</iframe>

glenngv
03-15-2012, 08:18 AM
As devnull69 pointed out, if the iframe url is in a different domain as the main page, you will not be able to get access to the contents of the iframe for security reasons.

2reikis
03-15-2012, 10:38 AM
You mean with ajax or something? Are you trying to stop the iframe content from appearing on the page?

devnull69
03-15-2012, 10:44 AM
The post from "CecilHartlely" was plain spam. Some "very funny" person(s) recently started to re-post postings from the same thread ... with no additional ad or something. This is just waste of time to the power of 10

2reikis
03-15-2012, 12:40 PM
hehehe, I was puzzled how my response failed to be programmatic.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum