faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

37 of 121 people (31%) answered Yes
Recently 3 of 10 people (30%) answered Yes


How can I get javascript to determine a browsers font setting and alter it to whatever I choose so that my site is cross-browser/font size compatible

Apr 4th, 2008 19:36
ha mo, Colin Fraser, Evan Heller,

Different browsers use their setups differently and mostly what you are 
trying to do may cause the browser, therefore the user a problem. I am 
not sure that too many people will like the idea of a web page changing 
their browser's settings.
I suspect your best bet would be to check their screen resolutions. 
As far as I am aware, all browsers support the screen object and this 
means the property values of width and height are available. This 
implies you can change those values or redirect the browser to a page 
you have prepared for a specific resolution. 
<script language="JavaScript"><!--
function screenres(){
 if (window.screen.width=='600') {
     location.href = '600.html'; }
 else {
     if (window.screen.width=='800')
         location.href = '800.html';
     else if (window.screen.width=='1024')
         location.href = '1024.html';
     else if (window.screen.width>'1024')
         location.href = 'other.html';   
<body onload="screenRes()">
This may be somewhat clumsy and there probably are better ways to handle 
this problem, but it should work with considerably less aggravation than 
trying to reset a user's browser.