Modifying Html TAGs within an IFRAME with JavaScript

0

I would like to modify a tag that is inside an iframe in my page.

I think it will become clearer with the script below:

The tag "streamurl" is inside the iframe code.

<iframe id="player_externo" src="https://openload.co/embed/zFec7SV5aFU"width="605" height="400" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" allowfullscreen="true"></iframe>


<script type="text/javascript">
tempo = 5;
tempo = tempo*1000;
setTimeout(function(){
    var download = document.getElementById('streamurl').innerHTML;
	document.getElementById('player_externo').src = "https://openload.co/stream/" +download;
	alert(download);
}, tempo);
</script>
    
asked by anonymous 03.10.2017 / 16:05

1 answer

0

You can use contentWindow or contentDocument .

var x = document.getElementById("player_externo");
var y = (x.contentWindow || x.contentDocument);
if (y.document)y = y.document;
var download = y.getElementById('streamurl').innerHTML;
x.src = "https://openload.co/stream/" +download;
alert(download);
    
03.10.2017 / 16:19