How can I append #somehash to all links on a page without depending on a JS framework?
Or is it possible to catch when someone clicks on a link and attach #somehash?
How can I append #somehash to all links on a page without depending on a JS framework?
Or is it possible to catch when someone clicks on a link and attach #somehash?
Make the server add hashed?
Otherwise you will need JS. PS, how do you plan to do anything useful with the hashes without JS enabled?
As pointed out, you're probably doing this the wrong way, but...
var links = document.getElementsByTagName('a');
for(var i = 0; i < links.length; i++) {
var link = links[i];
if (link.href.indexOf('#') < 0) {
link.href += '#somehash';
}
}