Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing background image once using either CSS or JavaScript [closed]

I've been asked by a friend to set up a web page whose background changes only once when any of the links are clicked. I've tried a few examples given on this site and looked at a few on Google, but they are pretty much all gallery-style cyclical changes. Perhaps I'm just frustrated and not seeing the trees for the forest...

The page is @ mysite/julie The images are @ mysite/julie/images/blogbka.png and /images/blogbk.png

I used the solution found below ( https://stackoverflow.com/a/11362465/1506620 )

Thank you all for your help.

like image 704
user1506620 Avatar asked Feb 14 '26 17:02

user1506620


1 Answers

var is=true;
document.body.onclick = function( e ) {
    if ( e.target.tagName === 'A' ) {
if(is){
document.body.style.background='url(http://adultdave.co.uk/julie/images/blogbka.png)';is=false;}
}
};

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!