Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up Can I copy text content from <iframe> to variable ?

    Hi world
    I have this code in my page

    PHP Code:
    <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"

  • #2
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Example
    I want to extract the contents of this page programmatically not manually
    http://playerplus.co.nu/test.php

  • #3
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    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.

  • #4
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by devnull69 View Post
    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"

  • #5
    Regular Coder 2reikis's Avatar
    Join Date
    Nov 2005
    Location
    California
    Posts
    167
    Thanks
    17
    Thanked 13 Times in 13 Posts
    This function assumes your iframe has an id if "myiframe".

    Code:
    	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

    Code:
    <iframe src="http://playerplus.co.nu/ipp.php" id="myiframe">
    
    </iframe>
    2Reikis
    I did not arrive at my understanding of the physical universe through my rational mind.
    Albert Einstein

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    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.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #7
    Regular Coder 2reikis's Avatar
    Join Date
    Nov 2005
    Location
    California
    Posts
    167
    Thanks
    17
    Thanked 13 Times in 13 Posts

    Not sure what you want

    You mean with ajax or something? Are you trying to stop the iframe content from appearing on the page?
    2Reikis
    I did not arrive at my understanding of the physical universe through my rational mind.
    Albert Einstein

  • #8
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    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

  • #9
    Regular Coder 2reikis's Avatar
    Join Date
    Nov 2005
    Location
    California
    Posts
    167
    Thanks
    17
    Thanked 13 Times in 13 Posts

    doh! Got me!

    hehehe, I was puzzled how my response failed to be programmatic.
    2Reikis
    I did not arrive at my understanding of the physical universe through my rational mind.
    Albert Einstein


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •