Random Weather Locations?
Does anyone know if there is a way to offer a weather widget for a website, which would randomly change the city location each time entering
the site or refreshing the page?
We have six locations, and so we do not favor one location, I would like too randomly display the weather for one of our locations on the index page.
I have achieved what I wanted by creating an index page that has a script which randomly loads one of six pages with each page having the weather widget for that location.
Here is the script,
<script>
var howMany = 5; //
max number of items listed below
var page = new Array(howMany+1);
page[0]="index1.html";
page[1]="index2.html";
page[2]="index3.html";
page[3]="index4.html";
page[4]="index5.html";
page[5]="index6.html";
function rndnumber(){
var randscript = -1;
while (randscript < 0 || randscript > howMany ||
isNaN(randscript)){
randscript = parseInt(Math.random()*(howMany+1));
}
return randscript;
}
quo = rndnumber();
quox = page[quo];
- window.location=(quox);
</script>
I am currently using the following from Accuweather for the weather widget. I believe this is old but still working. You can change the season image, "winter2" to spring1 or 2, summer1 or 2 or fall1 for different backgrounds.
<div style='width: 180px; height: 150px;
background-image: url( http://vortex.accuweather.com/adcbin/netweather_v2/backgrounds/winter2_180x150_bg.jpg
); background-repeat: no-repeat; background-color: #7facef;' ><div
id='NetweatherContainer' style='height: 138px;' >
<div align="center">
</script>
</div>
</div>
This works great but the problem is that if I need to make a change to one of the index pages I have to do that times six to keep things consistant.
Any suggestions?
