the javascript thingy


when i made this version of the site, i decided "instead of updating each page to add a button, i am going to use javascript for it!"

it took a bit of research, but i found out how to do it, and it's pretty easy. first off, we need to understand one line of code:

document.write(buttons);

pretty innocuous, right? but if used incorrectly, it can break how your website is shown. be careful !!

anyway, we put this line at the bottom of the script. the real meat is the buttons variable:

let buttons = ``;

this is where we put all of our buttons. for example:

let buttons = `<a href="https://syrupnx.space"><img src="/img/syrup.gif"></a>...`;

this is great and all, but now we need to actually write it to our page. this is where <script> comes in! we can put this where we want our html written, like so:

<marquee><script src="/scr/buttons.js"></script></marquee>

cool! but if you want to style these images, you'd have to modify each one in the script... or...

let buttons = `<span class="buttons">...buttons here...</span>`;

if you put your buttons in a span, you can apply styling to it with css like so:

span > a > img { ...styling... }

that is basically it. you can have a look at my button script for an example.

[buttons.js]