i have many different links on the page and instead of changing them one by one, i want to force them all to goto the same URL using Javascript (or php if possible)

Is there a way I can define where I want all URLs to go at the top of the page? so when a user clicks any link it will goto the URL specified in javascript?