Saturday 24 September 2011

Javascript to change background according to the current weather for website?

I want to make a website that changes the background according to the current weather of a city.

Example: if its sunny, i want the background of my website to be sunny and if the current weather is rainy i want my background to be rainy.

I make the wallpapers myselfJavascript to change background according to the current weather for website?You can make that with Javascript with a tool like Yahoo pipes, but it would be easier and simpler with a server side language, like PHP or ASP.

Firstly you'll need to find the source for your weather: so will you create a text file with the current conditions? Or will you connect to a website which has information about the weather? You'll need to locate a source for your information.

With a server-side language, connect/read the current conditions and supply the correct background image; you can either get the code to write to the CSS file or you can simply point the background-image CSS property to a server-side scripting file which can direct you to the correct image.

Otherwise, you'll need to write Javascript code (with Ajax, ideally) which connects to the source and locates the data and then manipulates the DOM to change it to the correct background image.

I would suggest the server-side option.
  • how to become a enterpreneur
  • get teenagers intrested
  •