SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast edgarzakaryan's Avatar
    Join Date
    Aug 2012
    Location
    Yerevan, Armenia
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Access iframe content

    Hi there.
    In my website I have iframe in which I put tinymce redactor. I'm trying to get content of that textarea, but I can't get it.
    It's returning value that was before editing.

    Here is my script.

    Code:
    <iframe src="ajax/load_tinymce.php" id="mce" height="500" width="100%"></iframe>
    
    $value = $('#mce').contents().find(textareaidhere).html()
    for example if in my textarea, I have default value written [text text text], and I'm editing that to [123 123 123], jquery returning me [text text text].

  2. #2
    SitePoint Enthusiast edgarzakaryan's Avatar
    Join Date
    Aug 2012
    Location
    Yerevan, Armenia
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As I see the problem why I can't get value, because there one more iframe. It's like iframe inside iframe.

    So using this I'm getting the content of the first iframe
    Code:
    $value = $('#mce').contents().find(textareaidhere).html()
    But I need get value of the textarea from iframe which is by itself in this first iframe .

  3. #3
    SitePoint Enthusiast edgarzakaryan's Avatar
    Join Date
    Aug 2012
    Location
    Yerevan, Armenia
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wink

    Hey, I got the solution.

    To access multiple iframes, I used this

    Code:
    $('#mcs').contents().find('iframe').contents().find('body').html()
    It's working like this. I'm selecting content of first iframe which has id [ mcs ], than I'm searching for ifreame in this content, and at the end I'm selecting content of body from last iframe.

    So this will get all body content from the second iframe.


Tags for this Thread

Bookmarks

Posting Permissions

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