Background color random change

Hi there,

My client wants the background color of the website to change randomly when a visitor clicks on a page in the menu. She wants 8 different, specified colors, to be randomly applied.

I found this link:

My questions are: is this code OK to use and should I add it to theme functions.php file?

Any other advices and/or experiences to share with me?

Thanks in advance, best regards,