JavaScript: stripTags

Published on

/* Strip html tags. reference: http://davidwalsh.name/essential-javascript-functions */ function stripTags(htmlstr) { var div = document.createElement(‘div’); div.innerHTML = htmlstr; return div.textContent; }

JavaScript: insertRule

Published on

/* Inserts a CSS style rule. Usage: sheet.insertRule(“header { float: left; opacity: 0.8; }”, 1);false reference: http://davidwalsh.name/essential-javascript-functions */ var sheet = (function() { // Create the <style> tag var style = document.createElement(‘style’); // Add a media (and/or media query) here if you’d like! // style.setAttribute(‘media’, ‘screen’) // style.setAttribute(‘media’, ‘only screen and (max-width : 1024px)’) // … Continue reading JavaScript: insertRule

JavaScript: htmlEntities

Published on

/* Replaces html entities. */ function htmlEntities(str) { return String(str).replace(/&/g, ‘&amp;’).replace(/</g, ‘&lt;’).replace(/>/g, ‘&gt;’).replace(/”/g, ‘&quot;’); }