Kanwal Gill Kanwal Gill - 6 months ago 47
Javascript Question

is it possible to put iframe value in textarea?

I have seen in some websites, such as Wordpress, that they have rich text editors with a toggle option with which you can see html code of what you are typing. Is there any way I can see the src of an iframe in a textarea?

<textarea name="textarea" id="textarea"></textarea>
<iframe name="editor"style="width:600px;height:500px"id="iframe"></iframe>
<input type ="button"id="btn"value="btn"/>



You can do this with an ajax $.get request

    var iframe_url = $("#iframe").attr('src');

    $("#textarea").val( 'loading...' );

    $.get( iframe_url, {}, function(response){
        $("#textarea").val( response );
    } );