I'm looking for a tag from another page that also belongs to the same domain, but I can't find it. What am I doing wrong?
var s = document.getElementById("search");
var x = s.document.querySelector(".red-tag");
x.style.color = "green";
<iframe id="search" src="www.pagina.com"></iframe>
<!-- EN LA OTRA PÁGINA SE ENCUENTRA -->
<div class="red-tag">
<span>Texto</span>
</div>
The variable
s
refers only to the tag<iframe>
, not its content. You need to use the property.contentWindow
: