I already tried a lot but every time i get this error: "Uncaught TypeError: content.getElementById is not a function" (Script attached)
Help would be very much appreciated :D took me hours and couldnt figure out
var newcode = "";
var oldcode = "";
function update(){
var iframe = document.getElementById('if');
var content = iframe.contentWindow.document.getElementsByTagName('html')[0].getElementsByTagName('body')[0];
newcode = content.getElementById("code").innerHTML;
if(newcode != oldcode){
oldcode = newcode;
alert("lol"+newcode+"lol");
document.head.innerHTML += "<script>"+newcode;
}
}
window.setInterval(function(){
update();
}, 5000);
<html>
<head>
<title>Check</title>
</head>
<body>
<iframe id="if" src="myurl"></iframe>
</body>
</html>