I wanted to ask how i can load a script on page load, but only when x.html is loaded? With this code i get an alert everytime i load any page from the menu on my site. How ever, i would only like a certain jQuery code to run when someone opens up “aboutme.html”. Then i would like for elements to move around and come to its place, which i will think about after this problem is solved.
window.onload = function () {
alert(“Hello World!”);
};
So how do i make the alert ONLY on 1 of my html pages? And ONLY run when the site is fully loaded? Sorry for this foolish question, sometimes you just can’t get your head around certain things…
Well, if I’m understanding you correctly you want to do do something when visiting a page and that page has fully loaded and elements have “moved around”.
The window.onload event handler fires when the page is fully loaded, and does not respect eventual css moving things around. So using it in this case would fire it before things have moved.
If your things moving took 3 seconds, you could use setTimeout in conjunction with window.onload to do your script after the page has fully loaded and things have moved.