
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…
This is my online portfolio, showcasing work created in the seven years I've been a graphic and web designer.
I also use the site as a development area where ideas and techniques are explored and commented upon.
Comments upon
Building a Site
Coding
Design
DOM
JavaScript
SEO
User Experience
XHTML
Articles
Using CSS frameworks
The client is always right.
This was bound to happen...
Nevil Brody's a busy boy
Making sIFR scale with font size
Ongoing development
Using sIFR in an elastic template.
Fixing a few bugs
Elastic template example
Elastic design continued…