iframe onload event AGAIN! (Noooooo!)

This code does work in the Squiffy app but not in Chrome or Edge browsers after I press "Build."

    window.myFunction = function() {
      var weather = document.getElementById("weather").contentWindow.document.body.innerHTML;
      var Temp = weather.split("temp")[1];
      var humid = weather.split("humidity")[1];
      var speed = weather.split("speed")[1];
      var pop = weather.split("pop")[1];
      var all = weather.split("all")[1];
      var TempK = Temp.substring(2,5);
      var humidity = humid.substring(2,4);
      var wind = speed.substring(2,5);
      var chance = pop.substring(4,6);
      var sky99 = all.substring(2,4);
      var sky100 = all.substring(2,5);
      squiffy.set("TempK", TempK);
      squiffy.set("humidity", humidity);
      squiffy.set("wind", wind);
      squiffy.set("chance", chance);
      squiffy.set("sky99", sky99);
      squiffy.set("sky100", sky100);
      };


**How's the weather?**
<iframe id="weather" onload="myFunction()" src="https://api.openweathermap.org/data/2.5/forecast?q=Chiayi%20City,%20TW&cnt=1&appid={I have a personal ID that I put here}" width="100%" height="180" style="border:0"></iframe>

Hello.

It might be a CORS thing. (The iframe source is on a different domain than the main page.) Not sure, though.

Can you press F12 to open your browser's dev tools, then look at the console to see what the error is (if there is an error)?

...or, if you post a link to the example game, I could check it out that way.

I tried to test it by copying and pasting your code, but I have no API key; so, I just get this: {"cod":401, "message": "Invalid API key. Please see http://openweathermap.org/faq#error401 for more info."}


Thanks again, K.V. I think it must be as you said in the other thread. I'll PM you my game and API key in the morning. It's midnight over here.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums