Web development
fromRaymondcamden
2 weeks agoLinks For You (1/10/26)
URL parameters can degrade web page performance; GitHub's relative-time-element uses Intl for localized relative dates and should include a title attribute for exact times.
<script type="text/javascript"> function sanitize(input) { return input .replace(/([^a-z\d\s]+)/gi, ' ') .replace(/(\s+)/gi, ' '); } // Parse the URL parameter function getParameterByName(name, url) { if (!url) url = window.location.href; name = name.replace(/[\[\]]/g, "\\$&"); var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, " ")); } // Give the parameter a variable name and sanitize var dynamicContent = sanitize(getParameterByName('donor')); var dynamicContent2 = sanitize(getParameterByName('amount')); //Output the text to the page document.getElementById("formText").innerText = dynamicContent document.getElementById("formText2").innerText = dynamicContent2 </script>