0

I am trying to have the embedded windy app below play automatically when a website is loaded, however, I am not able to get it to work using document.evaluate. Would someone be able to tell me what I am doing wrong in the example below?

var iframe = document.getElementById("frameID");
        var elmnt = iframe.contentWindow.document.evaluate(
  '//*[@*[starts-with(name(), "data-ref")]="play"]',
  document,
  null,
  XPathResult.ANY_TYPE,
  null
).iterateNext().click()
<html>
<body>

<iframe id="frameID" width="650" height="450" src="https://embed.windy.com/embed2.html?lat=28.855&lon=-81.687&detailLat=28.855&detailLon=-81.687&width=650&height=450&zoom=5&level=surface&overlay=radar&product=ecmwf&menu=&message=&marker=&calendar=now&pressure=&type=map&location=coordinates&detail=&metricWind=default&metricTemp=default&radarRange=-1" frameborder="0"></iframe>

</body>
</html>
KevsfastZ
  • 1
  • 1
  • 2
  • 1
    You can not execute javascript in an iframe that is in a different domain. Same Origin Policy – epascarello Aug 31 '22 at 18:29
  • Does this answer your question? [Get element from within an iFrame](https://stackoverflow.com/questions/1088544/get-element-from-within-an-iframe) – starball Sep 01 '22 at 04:24

0 Answers0