This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

javascript daily URL change
#3
Thanks, that works but I don't understand why it did not change every iFrame?

The code below is working.
I kept the search for .hourlyforecast but perhaps there is a more elegant way of specifying the wanted class or Custom name in the load event.
The forecastDate string is to get the local time instead of UTC.

Code:
$(function() {
  $('iframe').one('load', function() {
    let d = new Date();
    let forecastDate = d.getFullYear() + '-' + ('0' + (d.getMonth() + 1)).slice(-2) + '-' + ('0' + d.getDate()).slice(-2);
    $('.hourlyforecast').find('iframe').attr('src','https://reg.bom.gov.au/places/vic/melbourne/forecast/detailed/#d' + forecastDate);
  });
});
Reply


Messages In This Thread
javascript daily URL change - by sgraystar - 02.04.2024, 21:40
RE: javascript daily URL change - by admin - 03.04.2024, 07:47
RE: javascript daily URL change - by sgraystar - 04.04.2024, 00:37
RE: javascript daily URL change - by admin - 05.04.2024, 06:48

Forum Jump: