-3

For the website for my webcomic, I’m trying to make it so that everytime you visit/refresh the website the image changes to be a different character. I spent hours trying to get this code on my website to work so the image changes on refresh, and i almost got it, however the images are way too big for the page and I cant figure out how to resize them. I tried to edit the images themselves but this is only a temporary solution as they are blurry and low quality, which is an issue because this is meant to be a website showcasing my artwork, and I don’t want my art to end up blurry, especially since this is on the first page you visit. I don’t like to use a separate CSS file for my page, as they confuse me and I like to have everything in one html file, though if there really is no other way then I’m willing to forego it.

Here’s what I have for my html:

table style="width: 81%; margin-left: calc(9%); margin-right: calc(10%);"><tbody><tr><img id="furFag"/>
</td>

<script langauge = javascript>

function getRandomImage() {

var images = ['/assets/those_guys/1.png', '/assets/those_guys/2.png', '/assets/those_guys/3.png', '/assets/those_guys/4.png'];
var image = images[Math.floor(Math.random()*images.length)];
 
return image;

}
 
function displayRandomImage() {

var htmlImage = document.getElementById("furFag");
htmlImage.src = getRandomImage();

}
displayRandomImage();


var images = ['/assets/those_guys/2.png', '/assets/those_guys/3.png', '/assets/those_guys/4.png'];

var htmlImage = document.getElementById("furFag");


</script>

If anyone is able to help it’d be much appreciated!! Thank you :3

1 Answer 1

0
<img src = "yourimagelink"
width"400"
height"500"
/>

this should change the size of your image (you can change de pixels ofc to size it has you want it.

Sign up to request clarification or add additional context in comments.

1 Comment

Hi! I tried this, and unfortunately this didn’t end up working. Thank you for trying though! Have a wonderful day :3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.