pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: Bruce Momjian <bruce@momjian.us>
Cc: Thom Brown <thom@linux.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: jd@commandprompt.com, Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: Dave Page <dpage@pgadmin.org>
Cc: pgsql-docs@postgresql.org, Erik Rijkers <er@xs4all.nl>
Subject: Re: [pgsql-www] Example indenting
Date: Tue, 31 Aug 2010 16:16:46 -0400 (EDT)
Message-ID: <201008312016.o7VKGkt01212@momjian.us> (raw)
In-Reply-To: <201008311759.o7VHxl829004@momjian.us>

Bruce Momjian wrote:
> Thom Brown wrote:
> > On 31 August 2010 18:45, Bruce Momjian <bruce@momjian.us> wrote:
> > > Thom Brown wrote:
> > >> >> But the benefit of the javascript hack was that we weren't setting a
> > >> >> base font size for everything, we just bump up the relative font size
> > >> >> for elements which are monospaced by default.
> > >> >>
> > >> >> There's pros and cons to both approaches. ?I'm not sure which one you
> > >> >> guys prefer.
> > >> >
> > >> > If we are using Javascript, why can't we probe the font size and do
> > >> > something reasonable, e.g. make monospace larger only if it smaller than
> > >> > proportional?
> > >>
> > >> Hmm.. I don't know if the rendered font size is exposed to the DOM.
> > >
> > > I quick search shows it as document.body.style.fontSize:
> > >
> > > ? ? ? ?http://www.ehow.com/how_5924039_change-font-size-javascript.html
> > >
> > > I believe you can query a fixed-width attribute to find its font size.
> > > Would you like me to write some Javascript that illustrates that?
> > 
> > The code on that page shows that the value can be blank, suggesting it
> > only picks up applied CSS styles, not font sizes which are a result of
> > falling back on the defaults.
> 
> OK, let me dig around.

I found some sample code the is supposed to work in all browers.  I
tested it in Firefox and it worked.  It should work in Opera and IE as
well.  HTML/Javascript file attached.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +

Attachments:

/www/test/index.html (text/html, 652B) download <html> <title>test</title> <body> <!-- Detect default font size in browser. Idea from http://www.quirksmode.org/dom/getstyles.html --> <p id="test">hi</p> <p id="test2" style="font-family: monospace;">hi2</p> <script type="text/javascript"> function display_default_font_size(id) { var x = document.getElementById(id); if (x.currentStyle) var y = x.currentStyle['fontSize']; else if (window.getComputedStyle) var y = document.defaultView.getComputedStyle(x,null).getPropertyValue('font-size'); return y; } document.writeln(display_default_font_size('test')); document.writeln(display_default_font_size('test2')); </script> </body> </html>

view thread (110+ messages)  latest in thread

Message-ID: <201008312016.o7VKGkt01212@momjian.us>
Permalink:  ../201008312016.o7VKGkt01212@momjian.us/
Also on:    postgresql.org/message-id/201008312016.o7VKGkt01212@momjian.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: bruce@momjian.us, thom@linux.com, tgl@sss.pgh.pa.us, Kevin.Grittner@wicourts.gov, dpage@pgadmin.org, er@xs4all.nl
  Subject: Re: [pgsql-www] Example indenting
  In-Reply-To: <201008312016.o7VKGkt01212@momjian.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox