HTML Introduction to HTML and CSS HTML: The Structural Foundation of Web Pages and Applications Image Tags

CASEY KELLEHER
PRO
CASEY KELLEHER
Pro Student 658 Points

the copy and paste function of the picimg is not changing the pic everytime i refresh the worksheet, it stays the same??

When copy and pasting the picimg file into the html code it is supposed to generate a new picture every time you refresh but its staying the same??

1 Answer

Steven Parker
Steven Parker
130,610 Points

Your browser may be displaying a cached image instead of fetching a new one.

You can add a fake query string to your image URL to prevent the browser from using the cached version with a line of JavaScript:

document.querySelector("img").src += "?nocache=" + Math.random();

Note that this particular script will only work for the first image on the page, you may need a more specific selector otherwise.