I'm looking for a code that can make the user reload the page by clicking on something. I'm really fresh in Web and don't know how to do it.
When the User is clicking on a picture it will show the picture for X seconds then reload the page (to initial position : top).
Or if you know a JQuery animation ready to use, it would be easy to incorporate
In hope that you can help me. Thanks you
All you have to do is attach an onclick()
handler to the image, and then reload the window. To achieve a delay, you can use setTimeout()
. The 3000
in the following example correlates to 3000 milliseconds, or 3 seconds. You can adjust to suit :)
document.getElementById("sample").onclick = function() {
setTimeout(function() {
location.reload();
}, 3000);
}
<img id="sample" src="http://placehold.it/100">
Hope this helps! :)