Click to See Complete Forum and Search --> : Detecting Browser Text Size Changes?


hnorris
02-03-2003, 12:03 AM
Hello -

Does anybody know how to dynamically detect changes in
browser text size settings from within Javascript?
For example, if the user were to switch browser text
size from large to small while viewing a web page?
( If IE, top menu View->Text Size) I'm only interested
in WHEN a change occurs; I don't need to know which
text size setting the user has chosen.

I haven't found any standard DOM event handlers for this
purpose, although I've noticed that the window
onresize handler is triggered - but I don't know to
distinguish text size changes from resize events
caused by the user changing the browser window
size/dimensions - is there possibly detail info
associated with the resize event object which could
indicate a browser text size change? I'm trying to
find a general DOM standardized way to solve this
problem, but would be grateful for any suggestions,
even if browser specific in nature. Thanks for any
help you can offer!!

- Holten

khalidali63
02-03-2003, 07:57 AM
It does not seem to be possible( I could be wrong).
What he is trying to do is get the default browser settings.
and unless you give some properties to a div you can not retrieve them.
What I mean is if I have a div e.g
<div id="temp"></div>
its position is relative by default.
now if I wanted to access its properties say
document.getElementById("temp").style.fontSize;
It will not return anything unless in the div declaration i define a font-size property.

<div id="temp" style="font-size:16pt;"></div>

Now if try to get fonstSize I'll get it.
It will be interesting if some one can make it work or may be I am not taking a proper approach to it..

cheers

Khalid

hnorris
02-03-2003, 09:42 AM
Dave Clarke's excellent suggestion (thanks!) was one idea I had already considering trying, but agreed, it is a real hack. I just want to clarify though, I'm NOT trying to determine the exact browser text size setting - I just want to detect WHEN the user changes the browser text size. Given how much the browser text size impacts the display of web pages, it seems odd there isn't a simple, straight forward way to determine such info...

- Holten

hnorris
02-04-2003, 01:39 PM
This is a simple, lightweight method to detect browser text size changes, but is an IE 5+ specific solution. Insert this code in your page and Substitute alert with your own function:

<div
style="whatever:expression(this.h&&this.h!=this.offsetHeight?alert(this.
offsetHeight):false,this.h=this.offsetHeight);position:absolute">&nbsp;</div>

- Holten