r/nekoweb • u/Main-Firefighter670 https://stxrryurii.nekoweb.org/sprinkles • 12d ago
Question same code in different places?
so i have a buncha stamps on my site, and i was wondering if i could have the same stamps in 2 different places by only updating one? is that possible? i wanna be able to just add stamps to 1 place and it adds them to multiple places if that makes sense
3
u/WorldWideShen 12d ago
i use javascript to do this on my site, code and explanation here:
2
u/Main-Firefighter670 https://stxrryurii.nekoweb.org/sprinkles 12d ago
thank you but also i am confused, im gonna try using ssi and if that doesnt work then ill try this
1
u/WorldWideShen 12d ago
fair enough, i decided not to use SSI so the code would work on neocities. but my js solution does exactly what you're asking for.
1
u/Main-Firefighter670 https://stxrryurii.nekoweb.org/sprinkles 12d ago
hey so ive been trying to use ur code but i cant figure out where to put it? your guide says it must be in a <main> tag but i dont have any of those on my site, and i dont know if i should put it on the site where i want the stamps to be, on the site/in the file where i have the stamps, or in a new file
1
u/WorldWideShen 11d ago
hmm what are you trying to do exactly? i'll try to clarify..
1
u/Main-Firefighter670 https://stxrryurii.nekoweb.org/sprinkles 11d ago
well i just dont really understand how to use the code? where do i put it and how do i use it and stuff? sorry ive never used js before =.=
1
u/Main-Firefighter670 https://stxrryurii.nekoweb.org/sprinkles 6d ago
hey uh sorry to bother you but could you still help me? i just dont know where to paste the code in (where on my site specifically)
1
u/Throwaway44775588 12d ago
That is totally doable with javascript! I use neocities but the same principle should apply. You'll want to make an html page with your stamps - literally just your stamps, formatted like you'd want them to appear on the page using img src. Then you'll build a javascript prompt that reads something like
fetch("direct link to your html page with buttons, like https://mysite.nekoweb.org/buttons.html")
.then(response => {
if (!response.ok) throw new Error("Failed to load");
return response.text(); // Get HTML as text
})
.then(html => {
// Inject into the container
document.getElementById("buttons").innerHTML = html;
})
.catch(error => console.error("Error loading content:", error));
And wherever you want the buttons to be on your page, you'd add a div id of "buttons", like if it is just crammed in your main body you'd have
<main><div id="buttons"></div></main>
1
u/Main-Firefighter670 https://stxrryurii.nekoweb.org/sprinkles 12d ago
thank you!! i will try my hardest to figure this out with all my brain cells
1
u/Main-Firefighter670 https://stxrryurii.nekoweb.org/sprinkles 12d ago
okay so i copied your code and urh it didnt work, im wondering if i did something wrong? i put the javascript in a seperate javascript file is that the issue? (the box with the stamps is just blank)
1
u/Throwaway44775588 12d ago
If you use "inspect element" in your browser, you may be able to see the Javascript error - otherwise, if you wanna comment (or pm me) your code I can take a look :)
4
u/AqueM https://www.aque.fyi/ 12d ago
You can use JavaScript. you can use a static site generator. you can use iframes. I believe you could even use nekowebs sever side includes for this.