How to capture the value of the src attribute of an iframe?

1

I have to capture the value of an iframe attribute in pagina.html , from the parent page pai.html . I tried everything but I did not succeed.

pai.html :

<iframe id="meuframe" src="//www.site.com.br/fotos/pagina.html"></iframe>
<br></br>

<button onclick="iframejs();">icone</button>

<script>
    function iframejs() {
        var iframe = window.parent.meuframe.document.getElementById( "video_html" );
        alert( iframe.getAttribute( "src" ) );
    }
</script>

</body>
</html>

page.html

    <!DOCTYPE html>
    <html>
    ...

    <video id="video_html5" src="video.mp4" class="video-gs"></video> 

    ...
    </body>
    </html>
    
asked by anonymous 03.03.2017 / 14:21

2 answers

0

With jQuery, you can use the contents :

$('#meuframe').contents().find('#video_html').attr('src');
    
03.03.2017 / 14:51
0

I ended up using this in javascript

    var video = window.parent.meuframe.document.getElementById("video_html").src; 

but does not run on Chrome,

jquery also did not work!

   $('#meuframe').contents().find('#video_html').attr('src');

but in IE I had no problem

    
03.03.2017 / 17:52