Trigger code to run on page when an event of site occurs

Thanks Anney, thats working fine now. Great!