/ Published in: JavaScript
Run on document load - script checks fonts are not too small and resizes to 10pt if they are.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function MinimumFontSize() { // Create div with minimal content and move off-screen var XDivElement = document.createElement('div'); XDivElement.setAttribute('id', 'xDiv'); XDivElement.innerHTML = 'm'; document.body.appendChild(XDivElement); XDivElement = document.getElementById('xDiv'); XDivElement.style.border = '0'; XDivElement.style.padding = '0'; XDivElement.style.margin = '0'; XDivElement.style.textIndent = '0'; XDivElement.style.letterSpacing = '0'; XDivElement.style.fontSize = '1em'; XDivElement.style.position = 'absolute'; XDivElement.style.marginLeft = '-1000px'; // Element Created. Measure height. if (XDivElement.offsetHeight < "16") { tags = new Array ('body', 'div', 'a', 'td', 'th', 'p', 'span', 'h1', 'h2', 'h3'); for (j = 0; j < tags.length; j ++) { var getbody = document.getElementsByTagName(tags[j]).item(0); if (getbody) { getbody.style.fontSize = '10pt'; } } } }