I have html-pages with links where i want to attach a function to their onclick-event. One way to do it is of course:
<a href="save.php" onclick="save(); return false;" rel="save">Save</a>
But I know this is not the best practice. So instead I wait for window.onload, loop through the links and attach the save-function to the links with rel="save". The problem with this is that it waits until the whole page has finished loading which can be several seconds after the link is displayed and clickable.
So is there another way to do this? Avoiding onclick in the html but that makes it work immediately when the link is rendered.