468,532 Members | 1,716 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,532 developers. It's quick & easy.

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

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


Jul 23 '05 #1
1 1542
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>
Timo wrote:
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


Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by JAMESICUS | last post: by
17 posts views Thread by Harlan Messinger | last post: by
2 posts views Thread by Jim Ley | last post: by
5 posts views Thread by Dave Henson | last post: by
54 posts views Thread by richard_quick_uk | last post: by
3 posts views Thread by Brian Cryer | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.