Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #13124 > unrolled thread
| Started by | Dr.Kral@nyc.rr.com |
|---|---|
| First post | 2012-03-29 17:30 -0400 |
| Last post | 2012-03-29 18:22 -0700 |
| Articles | 10 — 5 participants |
Back to article view | Back to comp.lang.javascript
Browser Default Colors Dr.Kral@nyc.rr.com - 2012-03-29 17:30 -0400
Re: Browser Default Colors "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-03-30 06:50 +0000
Re: Browser Default Colors Dr.Kral@nyc.rr.com - 2012-03-30 14:08 -0400
Re: Browser Default Colors Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-03-30 20:59 +0200
Re: Browser Default Colors Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-03-30 20:46 +0200
Re: Browser Default Colors John G Harris <john@nospam.demon.co.uk> - 2012-03-31 11:49 +0100
Re: Browser Default Colors "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-03-31 11:49 +0000
Re: Browser Default Colors David Mark <dmark.cinsoft@gmail.com> - 2012-03-31 04:01 -0700
Re: Browser Default Colors Dr.Kral@nyc.rr.com - 2012-03-31 08:47 -0400
Re: Browser Default Colors David Mark <dmark.cinsoft@gmail.com> - 2012-03-29 18:22 -0700
| From | Dr.Kral@nyc.rr.com |
|---|---|
| Date | 2012-03-29 17:30 -0400 |
| Subject | Browser Default Colors |
| Message-ID | <q0l9n79p2tteamk95li9013sa1scbsothl@4ax.com> |
Browser Default Colors
I would like to get the default colors used by a browser using ECMAScript
from within the displayed page.
The function
document.getElementById("xxx").style.backgroundColor
only reports the value set by inline styles or style sheets.
The functions
elem=document.getElementById("xxx")
document.defaultView.getComputedStyle(elem, "").backgroundColor
and
document.getElementById("xxx").currentStyle.backgroundColor
do better and provide the actual rendered color value -- most of the time.
The value reported for the body and link backgrounds are given as
transparent or rgba(0,0,0,0) as the display shows the default background
color from the browser definitions. Is there a way to go one level deeper?
While I'm asking, I'll also ask about the link colors. If one check a
displayed link element one does get unvisited color reliably but browsers
(for security reasons) may lie about the visited color.
I have searched but only have learnt about the above and have not found how
to get deeper.
TIA
[toc] | [next] | [standalone]
| From | "Evertjan." <exjxw.hannivoort@interxnl.net> |
|---|---|
| Date | 2012-03-30 06:50 +0000 |
| Message-ID | <XnsA0265A04617ACeejj99@194.109.133.133> |
| In reply to | #13124 |
Dr.Kral wrote on 29 mrt 2012 in comp.lang.javascript: > I would like to get the default colors used by a browser using ECMAScript > from within the displayed page. > In fact you are asking for DOM-functions, not for ECMA-script functions. I cannot imagine why you would need to know the browser default colours as a web-page programmer. As a programmer you should set those colours yourself if you concerned if the view will be as you wish. Perhaps you would need them to "steal" that information for your statistical needs? Methinks that information, especially the dynamic colours of the <a>, are or should be hidden from the script under normal security-settings, as it is an improper way to measure the external links that are clicked. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Dr.Kral@nyc.rr.com |
|---|---|
| Date | 2012-03-30 14:08 -0400 |
| Message-ID | <chtbn71a9ph05nmetapkdul4jl58ho3ue2@4ax.com> |
| In reply to | #13128 |
On 30 Mar 2012 06:50:56 GMT, "Evertjan." <exjxw.hannivoort@interxnl.net> wrote in <XnsA0265A04617ACeejj99@194.109.133.133>: >Dr.Kral wrote on 29 mrt 2012 in comp.lang.javascript: >> I would like to get the default colors used by a browser using ECMAScript >> from within the displayed page. >> >In fact you are asking for DOM-functions, not for ECMA-script functions. Without splitting hairs, I'm asking for the script function that retrieves a parameter from the browser (background color) in a similar way to getting, say, window height and screen width. There must be some default style sheet (or equivalent) that has all the defaults parameters. >I cannot imagine why you would need to know the browser default colours as >a web-page programmer. As a programmer you should set those colours >yourself if you concerned if the view will be as you wish. One simple example -- swap color and background color in a section. Can't do it without knowing both for transparent text is not readable. >Methinks that information, especially the dynamic colours of the <a>, are >or should be hidden from the script under normal security-settings, as it >is an improper way to measure the external links that are clicked. Note I was asking about the default colors for link:visited not for a visited link element.
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2012-03-30 20:59 +0200 |
| Message-ID | <1803366.4W3vaeNJFY@PointedEars.de> |
| In reply to | #13131 |
Dr.Kral@nyc.rr.com wrote:
> On 30 Mar 2012 06:50:56 GMT, "Evertjan." <exjxw.hannivoort@interxnl.net>
> wrote in <XnsA0265A04617ACeejj99@194.109.133.133>:
>> Dr.Kral wrote on 29 mrt 2012 in comp.lang.javascript:
See, most of that is what I referred to in my other answer as unnecessary
and unwanted (because distracting) duplication of message header field
values in my other answer.
>>> I would like to get the default colors used by a browser using
>>> ECMAScript from within the displayed page.
>> In fact you are asking for DOM-functions, not for ECMA-script functions.
There are no "DOM-functions" and there is no "ECMA-script". There are DOM
(API) methods and there is ECMAScript. The W3C DOM Specification defines an
ECMAScript language binding for interface attributes and methods, and DOM
implementations allow an ECMAScript implementation to make use of those.
You are obviously not good at splitting hairs, so please don't.
> Without splitting hairs, I'm asking for the script function that retrieves
> a parameter from the browser (background color) in a similar way to
> getting, say, window height and screen width. There must be some default
> style sheet (or equivalent) that has all the defaults parameters.
There is, but it should be of no concern to script authors which is why they
cannot access it in all cases. If you are interested in the default value
as a developer, use a CSS inspector application (as included in all recent
Web browsers). But never rely on it.
>> I cannot imagine why you would need to know the browser default colours
>> as a web-page programmer. As a programmer you should set those colours
>> yourself if you concerned if the view will be as you wish.
>
> One simple example -- swap color and background color in a section. Can't
> do it without knowing both for transparent text is not readable.
AISB, if the body text color was declared, the body background color should
be declared as well (and vice-versa). If not, that is an authoring error as
the document is running the risk of being unreadable. So you can always
know the background color and there is no real problem switching background
and foreground color, regardless if this would ever be necessary or
advisable.
<http://www.w3.org/QA/Tips/color>
>> Methinks that information, especially the dynamic colours of the <a>, are
>> or should be hidden from the script under normal security-settings, as it
>> is an improper way to measure the external links that are clicked.
>
> Note I was asking about the default colors for link:visited not for a
> visited link element.
AFAIK the `:visited' pseudo-class does not apply to `link' elements.
<http://www.w3.org/TR/CSS2/selector.html#link-pseudo-classes>
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2012-03-30 20:46 +0200 |
| Message-ID | <1793833.mheAe9J7Na@PointedEars.de> |
| In reply to | #13124 |
Dr.Kral@nyc.rr.com wrote:
^^^^^^^^^^^^^^^^^^
It is of advantage if you post using your real name here.
> Browser Default Colors
As this is Network News, the subject of the message is already provided by
the Subject header field value. You do not have to and you should not
repeat that value in the message body. This applies to several other
message header fields as well.
> I would like to get the default colors used by a browser using ECMAScript
> from within the displayed page.
>
> The function
> document.getElementById("xxx").style.backgroundColor
> only reports the value set by inline styles or style sheets.
The property would only yield the value as declared in a `style' attribute,
if present, and it is evidently not a function.
> The functions
> elem=document.getElementById("xxx")
> document.defaultView.getComputedStyle(elem, "").backgroundColor
The proper (standards-compliant) property access is
document.defaultView.getComputedStyle(elem, null).backgroundColor
or
document.defaultView.getComputedStyle(
elem, null).getPropertyValue("background-color")
or
document.defaultView.getComputedStyle(
elem, null).getPropertyCSSValue("background-color")
whereas the second one should return a primitive value and the third one a
reference to an object (or `null').
> and
> document.getElementById("xxx").currentStyle.backgroundColor
There is also
document.getElementById("xxx").runtimeStyle.backgroundColor
in the MSHTML DOM.
> do better and provide the actual rendered color value -- most of the time.
In which instances have you observed which one to not provide it?
> The value reported for the body and link backgrounds are given as
> transparent or rgba(0,0,0,0) as the display shows the default background
> color from the browser definitions. Is there a way to go one level
> deeper?
No, you are at the deepest level accessible to script authors already. If
you disable all your author stylesheets (using the `disabled' property of
objects implementing the StyleSheet interface), those are most of the time
the values that are either the browser defaults or declared in a user
stylesheet overriding the defaults.
Keep in mind that the `body' element is not the root element of the
document, so the default background color might be provided by the root
element instead. However, authors should declare the background color of
the `body' element, unless they go with the default text color. So one
wonders what you think you will be needing this for.
> While I'm asking, I'll also ask about the link colors. If one check a
> displayed link element one does get unvisited color reliably but browsers
> (for security reasons) may lie about the visited color.
Correct. (Your *question* being?)
PointedEars
--
> If you get a bunch of authors […] that state the same "best practices"
> in any programming language, then you can bet who is wrong or right...
Not with javascript. Nonsense propagates like wildfire in this field.
-- Richard Cornford, comp.lang.javascript, 2011-11-14
[toc] | [prev] | [next] | [standalone]
| From | John G Harris <john@nospam.demon.co.uk> |
|---|---|
| Date | 2012-03-31 11:49 +0100 |
| Message-ID | <4z6MEVCsEudPFwLW@J.A830F0FF37FB96852AD08924D9443D28E23ED5CD> |
| In reply to | #13132 |
On Fri, 30 Mar 2012 at 20:46:53, in comp.lang.javascript, Thomas 'PointedEars' Lahn wrote: >Dr.Kral@nyc.rr.com wrote: >^^^^^^^^^^^^^^^^^^ >It is of advantage if you post using your real name here. > >> Browser Default Colors > >As this is Network News, the subject of the message is already provided by >the Subject header field value. You do not have to and you should not >repeat that value in the message body. <snip> Thomas wants to change the FAQ again. "Use the Subject: line to show the type of problem you have but include the question in the body as well." John -- John Harris
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exjxw.hannivoort@interxnl.net> |
|---|---|
| Date | 2012-03-31 11:49 +0000 |
| Message-ID | <XnsA0278C963F628eejj99@194.109.133.133> |
| In reply to | #13135 |
John G Harris wrote on 31 mrt 2012 in comp.lang.javascript: > On Fri, 30 Mar 2012 at 20:46:53, in comp.lang.javascript, Thomas > 'PointedEars' Lahn wrote: >>Dr.Kral@nyc.rr.com wrote: >>^^^^^^^^^^^^^^^^^^ >>It is of advantage if you post using your real name here. >> >>> Browser Default Colors >> >>As this is Network News, the subject of the message is already >>provided by the Subject header field value. You do not have to and >>you should not repeat that value in the message body. > <snip> > > Thomas wants to change the FAQ again. > > "Use the Subject: line to show the type of problem you have but > include the question in the body as well." What nonsense, Usenet Netiquette says that posting is always on topic. Responding on what is felt[!] to go wrong in a thread does not violate the thread itself. The FAQ is not netiquette nor charter, just advice in NG matters. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | David Mark <dmark.cinsoft@gmail.com> |
|---|---|
| Date | 2012-03-31 04:01 -0700 |
| Message-ID | <29f8e402-6d1f-4426-835d-8c709d169597@m13g2000yqc.googlegroups.com> |
| In reply to | #13135 |
On Mar 31, 6:49 am, John G Harris <j...@nospam.demon.co.uk> wrote: > On Fri, 30 Mar 2012 at 20:46:53, in comp.lang.javascript, Thomas'PointedEars' Lahn wrote: > >Dr.K...@nyc.rr.com wrote: > >^^^^^^^^^^^^^^^^^^ > >It is of advantage if you post using your real name here. > > >> Browser Default Colors > > >As this is Network News, the subject of the message is already provided by > >the Subject header field value. You do not have to and you should not > >repeat that value in the message body. > > <snip> > > Thomas wants to change the FAQ again. > > "Use the Subject: line to show the type of problem you have but include > the question in the body as well." > Speaking of that, after the disaster that was the last FAQ maintainer, has nobody stepped forward to handle FAQ updates? Somebody must have access to the server. If so, I recommend removing the edits to the browser sniffing page (and that ridiculous "edited by" attribution at the top) and restoring the old viewport article (it wasn't perfect, but it was far better than what's up there now). ISTM there was something screwy with the navigation the last time I looked for a link as well. And no, I'm doing it; suggestions are all I have time for at the moment.
[toc] | [prev] | [next] | [standalone]
| From | Dr.Kral@nyc.rr.com |
|---|---|
| Date | 2012-03-31 08:47 -0400 |
| Message-ID | <50vdn7l6qss4lv2j0b4odk2da8sm7qh6eg@4ax.com> |
| In reply to | #13132 |
On Fri, 30 Mar 2012 20:46:53 +0200, Thomas 'PointedEars' Lahn <PointedEars@web.de> wrote in <1793833.mheAe9J7Na@PointedEars.de>: >> I would like to get the default colors used by a browser using ECMAScript >> from within the displayed page. <snip> >> Is there a way to go one level deeper? > >No, you are at the deepest level accessible to script authors already. Thank you for a definitive answer (even though I would have preferred a different one). K.
[toc] | [prev] | [next] | [standalone]
| From | David Mark <dmark.cinsoft@gmail.com> |
|---|---|
| Date | 2012-03-29 18:22 -0700 |
| Message-ID | <1b51744c-7a89-4994-aa0f-e0293127d3d3@h20g2000yqd.googlegroups.com> |
| In reply to | #13124 |
On Mar 29, 5:30 pm, Dr.K...@nyc.rr.com wrote:
> Browser Default Colors
>
> I would like to get the default colors used by a browser using ECMAScript
> from within the displayed page.
I have to ask... Why?
>
> The function
> document.getElementById("xxx").style.backgroundColor
> only reports the value set by inline styles or style sheets.
No, inline only.
>
> The functions
> elem=document.getElementById("xxx")
> document.defaultView.getComputedStyle(elem, "").backgroundColor
> and
> document.getElementById("xxx").currentStyle.backgroundColor
> do better and provide the actual rendered color value -- most of the time.
The latter is not equivalent to the "computed" styles figured by the
former, though it may yield the same (or similar) results by
coincidence.
>
> The value reported for the body and link backgrounds are given as
> transparent or rgba(0,0,0,0) as the display shows the default background
> color from the browser definitions. Is there a way to go one level deeper?
You lost me.
>
> While I'm asking, I'll also ask about the link colors. If one check a
> displayed link element one does get unvisited color reliably but browsers
> (for security reasons) may lie about the visited color.
Wouldn't surprise me; it's certainly nothing to count on.
>
> I have searched but only have learnt about the above and have not found how
> to get deeper.
>
Define "deeper".
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web