hey please dont insert jquery, its already inserted!,
so remove this:
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
please read this on how to do something when a new page is loaded:
https://laytheme.com/documentation/custom-javascript.html#newpage-events
we have a custom javascript event window.laytheme.on("newpageshown", function(){
the onload event will only trigger one time, instead of every time you go to another page IF your website doesnt do a hard reload on navigation but instead uses the default ajax way of navigating
your website uses the normal ajax navigation
this is how i would do it. on newpageshown, it checks if the page is a project or not. if it is, it hides the star.
if its not a project it shows the star and moves it.
<script>
window.laytheme.on("newpageshown", function(){
if(jQuery('body').attr('data-type') == 'project'){
jQuery('#logo').hide();
} else {
jQuery('#logo').show();
move();
}
})
function move() {
let img = document.getElementById('logo');
let imgWidth = img.width; // Récupère la largeur actuelle de l'image
let imgHeight = img.height; // Récupère la hauteur actuelle de l'image
// Calcule les positions aléatoires en tenant compte des dimensions de l'image
let maxX = window.innerWidth - imgWidth; // Position horizontale maximale
let maxY = window.innerHeight - imgHeight; // Position verticale maximale
// Déplace l'image dans un emplacement aléatoire mais dans les limites de la fenêtre
img.style.left = Math.floor(Math.random() * maxX) + "px";
img.style.top = Math.floor(Math.random() * maxY) + "px";
}
</script>
you may also want to use this css
#logo{
pointer-events:none;
}
this way you can click things that are behind the star