accessibility: possible to determine browser-chosen point size of a relative font-size?

T

Timo

All my font-sizes are set as relative sizes in CSS (large, medium, small,
x-small, etc). Let's say something is set in CSS to be xx-large, but a
visually impaired user wants it displayed even bigger. Can a script
determine an element's absolute size, *as it is being rendered by the
browser*, and then increment the element's font-size in absolute terms?
Thanks!
Timo
 
V

Vincent van Beveren

Well, I have this script that makes a line span the screen size. You can
ofcourse always do something like document.body.style.fontSize='5cm';
This would make characters about 5 centimeters high.

<html>
<head>
<script language="JavaScript">
<!--

function calibrate() {
obj = document.getElementById('sizetest');
grow(0, obj.offsetHeight);
}


function grow(size, rowHeight) {
size+=10;
document.body.style.fontSize = size+'px';
window.setTimeout(
"growTest("+size+","+rowHeight+");",10);
}

function shrink(size, rowHeight) {
size-=1;
document.body.style.fontSize = size+'px';
window.setTimeout(
"shrinkTest("+size+","+rowHeight+");",10);
}

function shrinkTest(size, rowHeight) {
obj = document.getElementById('sizetest');
if (obj.offsetHeight>(rowHeight/2)) {
shrink(size, obj.offsetHeight);
}
}

function growTest(size, rowHeight) {
obj = document.getElementById('sizetest');
if (obj.offsetHeight>(rowHeight*2)) {
shrink(size, obj.offsetHeight);
} else {
grow(size, obj.offsetHeight);
}
}


<!-- -->
</script>

</head>


<body onLoad="calibrate();">

<SPAN id="sizetest">This should span a whole line</SPAN>

</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top