Posted By

DaveChild on 09/11/08


Tagged

accessibility


Versions (?)


Advertising

Website Promotion DIRECTORY is a crucial factor for all websites that need to gain better organic search engine rankings and increase website traffic.
Submitting your website as part of your Web Promotion strategy to our SEO friendly and high traffic Business Directory for review is an excellent way to gain a valuable backlink and increase your websites visibility online.

Submit Site


Who likes this?

1 person has marked this snippet as a favorite

alvaroisorna


JavaScript Minimum Font Size


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
  1. function MinimumFontSize() {
  2. // Create div with minimal content and move off-screen
  3. var XDivElement = document.createElement('div');
  4. XDivElement.setAttribute('id', 'xDiv');
  5. XDivElement.innerHTML = 'm';
  6. document.body.appendChild(XDivElement);
  7. XDivElement = document.getElementById('xDiv');
  8. XDivElement.style.border = '0';
  9. XDivElement.style.padding = '0';
  10. XDivElement.style.margin = '0';
  11. XDivElement.style.textIndent = '0';
  12. XDivElement.style.letterSpacing = '0';
  13. XDivElement.style.fontSize = '1em';
  14. XDivElement.style.position = 'absolute';
  15. XDivElement.style.marginLeft = '-1000px';
  16. // Element Created. Measure height.
  17. if (XDivElement.offsetHeight < "16") {
  18. tags = new Array ('body', 'div', 'a', 'td', 'th', 'p', 'span', 'h1', 'h2', 'h3');
  19. for (j = 0; j < tags.length; j ++) {
  20. var getbody = document.getElementsByTagName(tags[j]).item(0);
  21. if (getbody) {
  22. getbody.style.fontSize = '10pt';
  23. }
  24. }
  25. }
  26. }

Report this snippet 

You need to login to post a comment.

Download royalty free graphics