Where is exact code / problem?
Best I can do here is guess.
You need to use same generation process every time you generate color, end up with same color and apply it to desired elements in a way that satisfies you.
Here is simple way, in HTML use
<some parent element onload="loadColors()">
Now every time that element gets loaded into DOM (and it will on 1st visit as well as refresh) it will execute your function.
And in JS:
var loadcolors = function(){
// your process to generate color here
var yourGeneratedColor = ???
// bind that color to your elements, for example:
document.getElementById('Id-of-your-element').backgroundColor = your GeneratedColor;
}
If you are using random with seeding or the generation process is very resource heavy you might opt to use cookie or local storage to hold on to color once you have generated it. This way you generate it 1st time and only if the resource where you stored it gets destroyed.
EDIT - Answer to the comment:
If you only wanna input 1 color (or couple of) you can do it simple.
var yourColor = color + ""; // to make sure its string
localStorage.setItem('oneColor', yourColor); // store color under oneColor name in local storage
var retrievedColor = localStorage.getItem('oneColor'); // retrieve it's value
If you need to store many colors, you wanna store them all to object and then stringify them before saving.
var myColors = {
// object with my colors or array of colors, even arrays of colors..
}
// Put the object into storage
localStorage.setItem('storedColors', JSON.stringify(myColors));
// Retrieve the object from storage
var retrievedColors = localStorage.getItem('storedColors');
You can still use the onload I showed you above and in that function check if color object or color is present in local storage. If not generate and store them, if it's there just load it and apply to elements.
To check if something is there simply try to retrieve it, and if it's null it's not there.
if (localStorage.getItem("item") === null) // not there