Comments

Making sIFR scale with font size :: Oct 28, 08:12 AM

I’ve written a JavaScript function to allow sIFR text to scale with the elastic template.

The following is a script that listens for a change in template width; the width is sized in ems as is the font. If a change is detected then the do_sIFR() function is called in the replacement JavaScript.


var pageWidthSave = '';
var pageWidth = '';
function saveWidth() {
pageWidthSave = document.getElementById('Page').offsetWidth;
//alert(pageWidthSave);
}
function getWidth() {
pageWidth = document.getElementById('Page').offsetWidth;
//alert(pageWidth);
}
function evaluate() {
getWidth();
if(pageWidth==pageWidthSave) {
//alert("match");
}
if(pageWidth!=pageWidthSave) {
saveWidth();
do_sIFR();
//alert("no match");
}
}
function pageChange() {
var interval_name = setInterval("evaluate()", 1000);
}

Now I’m sure this may not be the optimum way to achieve this functionality why not let me know…