// Get all the links on the page var links = document.getElementsByTagName('a'); // Loop through each link for (var i = 0; i < links.length; i++) { var link = links[i]; // Get the current href attribute var href = link.getAttribute('href'); // Check if the href ends with '.htm' if (href.endsWith('.htm')) { // Replace the '.htm' extension with '.html' var newHref = href.replace(/\.htm$/, '.html'); // Update the href attribute with the new value link.setAttribute('href', newHref); } }