473,414 Members | 1,729 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Desperate, need javascript to covert a number to a color.


I'm going insane!!!!!

I set a font color using documentDOTexecuteCommand("ForeColor").

That works, but now I'm trying to read the color in another method. I
used documentDOTqueryCommandValue("ForeColor"). This method just
returns a number, and I can't figure out what the numbers are. I know
they have something to do with a color, but without knowing what they
are, it's hard to find help on how to convert them to something I can
use (hex, rgb). Here are two examples:
(Green returns 32768, Blue returns 16711689)

So, does anybody a)know what these numbers are? b)know how to convert
them to something more useful, or c)know how to generate these numbers
from a System.Drawing.Color in c#?

NOTE: DOT is due to the "no code" error on devdex. I didn't think I'd
get away with the real dots. Thank you in advance for your help!
Big Dave

*** Sent via Developersdex http://www.developersdex.com ***
Nov 23 '05 #1
7 1539
Big Dave wrote:
I'm going insane!!!!!

I set a font color using documentDOTexecuteCommand("ForeColor").

---------------------------^^^^^^^^^^^^^^^^^^^^^^^^^

Do you mean the Microsoft proprietary document.execCommand() method?

If so, this may help:

<URL:http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/execcommand.asp>
Expect it to work only in IE.

[...]
--
Rob
Nov 23 '05 #2
That's the one, my company uses only IE, so it shouldn't be a problem.
I've got that part working, it's the return value of those colors. I
can't find anything that explains what they are or how to convert them.
They aren't RGB or hex. I need to find out how to convert them to
something I can use.

Big Dave

*** Sent via Developersdex http://www.developersdex.com ***
Nov 23 '05 #3
Big Dave wrote:
That's the one, my company uses only IE, so it shouldn't be a problem.
I've got that part working, it's the return value of those colors. I
can't find anything that explains what they are or how to convert them.
They aren't RGB or hex. I need to find out how to convert them to
something I can use.

Big Dave

*** Sent via Developersdex http://www.developersdex.com ***


If you read the following post[1], it will tell you how to use
getComputedStyle and getCurrentStyle to get an element's properties.
From memory, IE will return colours exactly as they are set. So if
they are set using 'red', 'blue', etc. then that is what will be returned.

Mapping from RGB to colour names might be more easily achieved in
Firefox or another Geko browser, as they always report RGB values no
matter how the colour is set. It would take maybe 10 minutes to get
something that goes through all the named colours and prints out their
RGB equivalents. Conversion to hex should then be (even more) trivial.
1.
<URL:http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/c532483403801387/56c34b393de436ab?q=getcomputedstyle&rnum=1#56c34b3 93de436ab>

--
Rob
Nov 23 '05 #4
vdP
Big Dave wrote:
That works, but now I'm trying to read the color in another method. I
used documentDOTqueryCommandValue("ForeColor"). This method just
returns a number, and I can't figure out what the numbers are. I know
they have something to do with a color, but without knowing what they
are, it's hard to find help on how to convert them to something I can
use (hex, rgb). Here are two examples:
(Green returns 32768, Blue returns 16711689)


Are you sure these aren't rgb-values ? In hex the numbers read "00 80
00" (green) and "FF 00 09" (blue). The rgb-values of green and blue as
defined for html are "#00 80 00" and "#00 00 FF". So it seems that these
numbers are in rgb-format with the order of the three colors reversed. I
don't know about the 09 in the blue value, could it be a typo ?

vdP
Nov 23 '05 #5
vdP wrote:
Big Dave wrote:
That works, but now I'm trying to read the color in another method. I
used documentDOTqueryCommandValue("ForeColor"). This method just
returns a number, and I can't figure out what the numbers are. I know
they have something to do with a color, but without knowing what they
are, it's hard to find help on how to convert them to something I can
use (hex, rgb). Here are two examples:
(Green returns 32768, Blue returns 16711689)

Are you sure these aren't rgb-values ? In hex the numbers read "00 80
00" (green) and "FF 00 09" (blue). The rgb-values of green and blue as
defined for html are "#00 80 00" and "#00 00 FF". So it seems that these
numbers are in rgb-format with the order of the three colors reversed. I
don't know about the 09 in the blue value, could it be a typo ?


I would have expected 'green' to be #00ff00, but that is 'lime'. The
official reference is here:

<URL:http://www.w3.org/TR/html4/types.html#type-color>
The CSS 2.1 (work in progress) reference is here (it has bigger colour
swatches):

<URL:http://www.w3.org/TR/CSS21/syndata.html#value-def-color>
--
Rob
Nov 23 '05 #6
Big Dave wrote:
I'm going insane!!!!!


One can see that.
SCNR

PointedEars
--
Five exclamation marks, the sure sign of an insane mind.
-- Terry Pratchett in "Reaper Man"
Nov 23 '05 #7
On 2005-11-22, Big Dave <pr******************@yahoo.com> wrote:

I'm going insane!!!!!

I set a font color using documentDOTexecuteCommand("ForeColor").

That works, but now I'm trying to read the color in another method. I
used documentDOTqueryCommandValue("ForeColor"). This method just
returns a number, and I can't figure out what the numbers are. I know
they have something to do with a color, but without knowing what they
are, it's hard to find help on how to convert them to something I can
use (hex, rgb). Here are two examples:
(Green returns 32768, Blue returns 16711689)


try converting them to hex, your "green" looks like "0x008000"
and blue like "0xFF0009"

Bye.
Jasen
Nov 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Tank | last post by:
I have had this post up here when i was trying to figure out how to make leading zeros and have been able to fudge that to work. I am now have trouble getting the loop that makes the folders to...
2
by: Arthur | last post by:
Given the coordinates of a point on the screen (such as 185,185), how do you get the color of said point using VB.NET 2003. I have looked EVERYWHERE for this, but to no avail. All the examples...
6
by: billj2 | last post by:
Hello, I have a web app that needs the follwing settings Tools/internet options/settings/ Check for newer versions of stored pages. I can not rely on the users to do this. Is there any...
3
by: Cindy Liu | last post by:
Hi Everyone, In .Net we have XmlSerializer to convert c# class to xml, or vice versa. Do we have any APIs to convert c# class to XSD? Thanks in advance, Cindy
3
by: SpamProof | last post by:
I got an animated gif that is a barber pole spinning that I want to use as a progress bar. The problem is that is stops spinning (shows 1 frame) when my browser is processing a submited request...
2
by: this one | last post by:
I have the following code <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="JavaScript"...
1
by: iporter | last post by:
Below is some VB Script - I can't figure out how to convert it to javascript. Below that, I've put my best attempt at as far as I got - can anyone help me out correcting and completing it? ...
19
by: fx5900 | last post by:
Hi, i am trying to convert an .osm (openstreetmap) file into gml format and finally to shapefile given this wiki info http://wiki.openstreetmap.org/index.php/GML. I'm using windows and when i...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.