473,433 Members | 2,073 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,433 software developers and data experts.

how to get color value of character

254 100+
Hi

I want to find the color vaule of text which is of different color when user will move mouse on the text/charector.It should display its color value in RGB format.
like


Code: ( text )
<p>Hello Muksh Kumar. Welcome to thescripts.com!
Apr 8 '08 #1
7 1953
gits
5,390 Expert Mod 4TB
hi ...

let me give you an idea to start with:

[HTML]
<script type="text/javascript">

function show_color(event) {
var color = null;
var node = typeof window.event != 'undefined' ?
event.srcElement : event.target;

if (typeof window.getComputedStyle != 'undefined') {
color = window.getComputedStyle(node, '').getPropertyValue('color');
} else if (typeof node.currentStyle != 'undefined') {
color = node.currentStyle.color;
}

alert(color);
}

</script>

<body>
<div onclick="show_color(event);"> test </div>
</body>
[/HTML]
kind regards
Apr 8 '08 #2
mukeshrasm
254 100+
hi ...

let me give you an idea to start with:

[HTML]
<script type="text/javascript">

function show_color(event) {
var color = null;
var node = typeof window.event != 'undefined' ?
event.srcElement : event.target;

if (typeof window.getComputedStyle != 'undefined') {
color = window.getComputedStyle(node, '').getPropertyValue('color');
} else if (typeof node.currentStyle != 'undefined') {
color = node.currentStyle.color;
}

alert(color);
}

</script>

<body>
<div onclick="show_color(event);"> test </div>
</body>
[/HTML]
kind regards
Thanks Buddy! you really did a good job. Thanks lot
one more thing from where I can learn more about this topics
Apr 9 '08 #3
gits
5,390 Expert Mod 4TB
no problem ;) ... post back to the forum anytime you have more questions ...

kind regards
Apr 9 '08 #4
mukeshrasm
254 100+
Thanks dear

Now if instead of text I use some image then how can I get the value of color of that Image?
Apr 9 '08 #5
gits
5,390 Expert Mod 4TB
i'm sorry ... but i'm quite sure that you cannot do that with javascript since the image is just a included external source and javascript has capabilities to retrieve html, css, js or browser-properties but we have no image-manipulation capabilities ... except retrieveing/setting its dimensions or attributes of the node itself (html-tag) ... but not the src ...

kind regards
Apr 9 '08 #6
mukeshrasm
254 100+
i'm sorry ... but i'm quite sure that you cannot do that with javascript since the image is just a included external source and javascript has capabilities to retrieve html, css, js or browser-properties but we have no image-manipulation capabilities ... except retrieveing/setting its dimensions or attributes of the node itself (html-tag) ... but not the src ...

kind regards

Hi
might be you are right but how one can view the RGB value of image when some tool is used in that case also we drag/click the object and corresponding value of the image comes. Might be I asked some foolish thing but there is way to do it.
Apr 9 '08 #7
gits
5,390 Expert Mod 4TB
i remember this thread ... might be you could start from there to more explorations ...

kind regards
Apr 9 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: lkrubner | last post by:
I know I'm missing something obvious, but I looked hard at this page and did not see the format of the return specified: http://us3.php.net/manual/en/function.ord.php >From the limited example...
15
by: Craig Wagner | last post by:
I have a situation where I have a series of character codes stored in the database. In some cases they are the ASCII value of the character, in other cases they are the > 127 character code value...
0
by: Craig Wagner | last post by:
I have a situation where I have a series of character codes stored in the database. In some cases they are the ASCII value of the character, in other cases they are the > 127 character code value...
8
by: farah727rash | last post by:
Hi all, I am trying to find the numerical value of a string that stores a two digit number. I have found the numerical value of a char as: char character; cin >character; int number =...
5
by: Just D | last post by:
All, Any valuable idea about subj: "The '%' character, hexadecimal value 0x25" ? I tried to google, but nothing interesting was found. Is it IIS settings problem, user side problem or...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.