Jquery how to change your website background?
Tags: javascript,jquery,css,web-site-project
Problem :
In my website, I have css like this:
body {
background: #FFF url(../images/bg.jpg) no-repeat center fixed;
}
So it set my background image, and what I want to do is when user load some page the background image is change, not only for this page he is current on but for all.
How can I do this ?
For now I have script like this:
<script>
document.body.style.background="#FFF url('../images/bg2.png') no-repeat center fixed";
</script>
So it change my background image but only for that current page, others all loaded with default background image defined in css :(
i didnt mention that the name of image is provided in the page where i want to change that bacground and it is dynamic
USER ACTION EXAMPLE: here we are going to website like www.example.com and there is some bacground i change page to www.example.com/account i have the same bacground and when i go to www.example.com/change i want to change my bacground image so when no i go again to www.example.com/account the image is also changed
Solution :
Use HTML5 localStorage
to store the style.
Then when load:
$("body").css("background",localStorage.style);