codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  javascript, get the color assigned by class  Claude Martin at 11:47 on Thursday, January 20, 2005
 

hi.

I have a problem with javascript. i use something like that:

<style>
.foo { background-color:green; }
</style>

<input name="theName" class="foo" type=button onclick="getcolors(this)" id=":-(" value="click">

<input name="theName" style="background-color:green;" type=button onclick="getcolors(this)" id=":-)" value="click">

<script>
function getcolors(element) {
alert('Color of '+element.id+' = '+element.style.backgroundColor);
}
</script>

why cant i get the color if its from a class? it doesnt make sense to me. whats the difference of using a class ot using the style attribute.

i tested it on Opera and IE. both times only one button worked as expected.



  Re: javascript, get the color assigned by class  tgreer at 15:54 on Thursday, January 20, 2005
 

I think you found a legitimate bug. I don't know what that doesn't work. It works if you use the same syntax to SET the background color, but not to retrieve or display it. Maybe it has to be cast to a string? I don't know and don't have a lot of time today to experiment. I thought, though, I should give you the courtesy of a reply. Your code looks correct, but doesn't work for me either.



  Re: javascript, get the color assigned by class  Kjazwilty at 23:26 on Wednesday, March 30, 2005
 

IE:
style = element.currentStyle.backgroundColor;

MOZ:
style = document.defaultView.getComputedStyle(element, '').getPropertyValue("backgroundColor");
(Note; always return rgb(r,g,b) value.)

So..:
<script language="JavaScript" type="text/javascript">
function getcolors(element) {
alert('Color of '+element.id+' = '+getStyle(element));
}

function getStyle(el) {
if(el.currentStyle)
return el.currentStyle.backgroundColor;
if(document.defaultView)
return document.defaultView.getComputedStyle(el, '').getPropertyValue("background-color");
return "Don\'t know how to get color";
}
</script>

Returns:
IE: green
MOZ: rgb(0,128,0)

Br,


<Added>


...sorry slipped,:

in MOZ you must use the css property name.
Example: getPropertyValue("background-color"); and NOT getPropertyValue("backgroundColor");

MOZ:
WRONG:
var style = document.defaultView.getComputedStyle(element, '').getPropertyValue("backgroundColor");

Coorect:
var style = document.defaultView.getComputedStyle(element, '').getPropertyValue("background-color");

  Re: javascript, get the color assigned by class  brian500 at 10:37 on Saturday, December 11, 2010
 

Example: If I go to the home page, I want the "Home" left-menu link to be black, instead of red. However, I want this to be automated using javascript or something, so that the browser would see that I am currently viewing "index.html" (the Home page), and so that specific link should be black, not red. Similarily, if I visit the "Contact" page, because I am viewing contact.html and the link is "contact.html" in the menu, I want that link to be black, not red.Example: If I go to the home page, I want the "Home" left-menu link to be black, instead of red. However, I want this to be automated using javascript or something, so that the browser would see that I am currently viewing "index.html" (the Home page), and so that specific link should be black, not red. Similarily, if I visit the "Contact" page, because I am viewing contact.html and the link is "contact.html" in the menu, I want that link to be black, not red.

70-272 | 117-201 | JN0-570 | 156-315 | COG-112 | 117-202 | JK0-016 | HP2-Z06 | \ HP2-T19 | HP2-Q04 \ HP0-J33 | F50-531 | E20-501 | 000-966


  Re: javascript, get the color assigned by class  HG678 at 10:46 on Tuesday, December 14, 2010
 


Wonderful.

Share a website with you ,

put this url in google sirch

(http://www.aamall.us )

Believe you will love it.

We accept any form of payment

  Re: javascript, get the color assigned by class  dada123 at 06:29 on Wednesday, April 13, 2011
 

Air Jordan 1
Air Jordan 2
Air Jordan 3
Air Jordan 4
Air Jordan 5
Air Jordan 6
Air Jordan 7
Air Jordan 8
Air Jordan 9
Air Jordan 10
Air Jordan 11
Air Jordan 12
Air Jordan 13
Air Jordan 14
Air Jordan 16
Air Jordan 17
Air Jordan 18
Air Jordan 19
Air Jordan 2009
Air Jordan 2010
Air Jordan XX3
Air Jordans Fusions
Jordan Fusion 4
Jordan Fusion 5
Jordan Fusion 6
Jordan Fusion 9
Jordan Fusion 10
Jordan Fusion 12
Jordan 6 Rings
Jordan Spizikes
Jordan 60+
cheap jodans
Patrick Kane Authentic Jersey
Antti Niemi Authentic JerseyPatrick Kane Authentic Jersey
Antti Niemi Authentic Jersey
Bobby Hull Authentic Jersey
Brian Campbell Authentic Jersey
Jonathan Toews Authentic Jersey
Patrick Sharp Authentic Jersey
Stan Mikita Authentic Jersey
Adam Burish Authentic Jersey
Andrew Ladd Authentic Jersey
Ben Eager Authentic Jersey
Brent Seabrook Authentic Jersey
Brent Sopel Authentic Jersey
Cristobal Huet Authentic Jersey
Dave Bolland Authentic Jersey
Duncan Keith Authentic Jersey
Dustin Byfuglien Authentic Jersey
Jeremy Roenick Authentic Jersey
John Madden Authentic Jersey
Keith Magnuson Authentic Jersey
Kris Versteeg Authentic Jersey
Marian Hossa Authentic Jersey
Martin Havlat Authentic Jersey
Nikals Hjalmarsson Authentic Jersey
Tomas Kopecky Authentic Jersey
Tony Esposito Authentic Jersey
Troy Brouwer Authentic Jersey

  Re: javascript, get the color assigned by class  dabora at 07:04 on Friday, April 22, 2011
 

Adobe has this neat little tool called the slice tool that you use to cut up your image so it will work in a web page. What I found was MS Paint is able to do this too, not as easily as Photoshop does it but it is still doable. So all you will need to start creating quality web pages, is Notepad, MS Paint, and Windows Calculator. So we will now open up MS Paint and go to "Image" and select "Attributes" or press Ctrl+E and change your size to 800x600 or what ever size you want your web page to be.

___________________________________________________

pass4sure| pass4sure ccna| pass4sure security+| pass4sure ccnp| pass4sure cissp| pass4sure ccda| pass4sure network+| pass4sure ccie| pass4sure itil| pass4sure ccsp


  Re: javascript, get the color assigned by class  ping123 at 10:16 on Thursday, April 28, 2011
 

Finance is the science of funds management. The accepted areas of accounts are business finance scwcd dumps, claimed finance(private finance), and accessible finance. Accounts includes extenuative money and generally includes lending money. The acreage of accounts deals with the concepts of time, money, accident and how they are interrelated. It additionally deals with how money is spent and budgeted.

One angle of accounts is through individuals and business organizations, which drop money in a bank. The coffer again lends the money out to added individuals or corporations for burning or advance and accuse absorption on the loans 646-205 dumps.

Loans accept become more packaged for resale, acceptation that an broker buys the accommodation (debt) from a coffer or anon from a corporation. Bonds are debt instruments awash to investors for organizations such as companies, governments or charities. The broker can again authority the debt and aggregate the absorption or advertise the debt on a accessory market. Banks are the capital facilitators of allotment through the accouterment of credit, although clandestine equity, alternate funds, barrier funds, and added organizations accept become important as they advance in assorted forms of debt. Banking assets, accepted as investments, 000-107 dumps are financially managed with accurate absorption to banking accident administration to ascendancy banking risk. Banking instruments acquiesce abounding forms of securitized assets to be traded on balance exchanges such as banal exchanges, including debt such as bonds as able-bodied as disinterestedness in about traded corporations.

Central banks, such as the Federal Reserve System banks in the United States and Coffer of England in the United Kingdom, are able players in accessible finance, acting as lenders of aftermost resort as able-bodied as able influences on budgetary and acclaim altitude in the economy 646-230 dumps.

  Re: javascript, get the color assigned by class  ladygaga at 07:47 on Tuesday, June 14, 2011
 

christian louboutin pumps
christian louboutin black pumps
Cheap tory burch
fake tory burch flats
fake tory burch shoes
replica tory burch shoes
fake tory burch
tory burch replica shoes


  Re: javascript, get the color assigned by class  wwwkan123 at 05:59 on Friday, June 24, 2011
 



Today I found a wonderful website,the site contained:

wedding dresses


cheap wedding dresses


Junior Bridesmaid Dresses


Cheap Homecoming Dresses


Cheap Quinceanera Dresses


Inexpensive bridesmaid dresses


Wholesale wedding dress


Wholesale wedding dress


Discount wedding dresses


Cheap Maternity Wedding Dresses


A-Line Wedding Dresses


Cheap Couture Wedding Dresses


Cheap Beach Wedding Dresses


Cheap Casual Wedding Dresses


Cheap Simple Wedding Dresses


Cheap Modest Wedding Dresses


Cheap Special Occasion Dresses


Cheap Evening Dresses


Cheap Prom Dresses


Cheap Little Black Dresses


Cheap Plus Size Wedding Dresses


Pink Wedding Dresses


Cheap Wedding Party Dresses


Cheap Bridesmaid Dresses


Cheap Flower Girl Dresses


Cheap Mother of the Bride Dresses

victoria's secret,

cheap wedding dresses,wholesale wedding dress,Wedding dresses 2011,Plus Size Wedding Dress wholesale,Couture Wedding Dress wholesale,Formal Wedding Dress wholesale,Bridesmaid Dresses wholesale,Discount Bridesmaid Dress wholesale,Junior Bridesmaids Dresses wholesale,Maternity Bridesmaid Dress wholesale,Cocktail Dress wholesale,Prom Dress wholesale,Evening Dress wholesale,Sexy Evening Dress wholesale,Stardoll Dress wholesale,Quinceanera Dress wholesale,Mother of the Bride Dress,Flower Girl Dress,Wedding Accessories wholesale


  Re: javascript, get the color assigned by class  jasmine at 05:20 on Wednesday, July 27, 2011
 

It was good to see your post. It is such an important topic and ignored by so many, even professionals. I thank you to help making people more aware of possible issues. Great stuff as usual.
1Y0-A21
E20-335
E20-522
199-01
156-315.71
156-215.70
HP0-Y37
HH0-110


  Re: javascript, get the color assigned by class  breakfastfood09 at 05:54 on Monday, August 01, 2011
 

A century ago, American farmers healthy breakfast and city-dwellers alike piled breakfast low calorie diet plan plates high with meat, potatoes, gravy, eggs, bread, and healthy breakfast ideas/strong> sometimes pastries. Not much has eggs breakfast recipe changed.A 21st century leisurely breakfast often healthy breakfast foods consists of sausage or bacon, eggs, fried potatoes, gravy, healthy breakfast cookie recipe and waffles or pancakes smothered healthy breakfast cereal choices in butter and syrup or topped with healthy breakfast recipes sweetened fruit compote low calorie breakfast recipes and whipped cream.This breakfast is high in saturated fat and low in vitamins and healthy breakfast diet for kids other important nutrients. People who engage average breakfast cereal choices in regular hard work similar to healthy breakfast choices our ancestors, like the Amish, might get away with diet breakfast recipes eating that diet, but the rest of healthy eating tips America is at healthy breakfast dishes for kids increased risk of obesity and chronic diseases, such as cancer and diabetes.Another typical breakfast hurriedly gobbled down healthy recipes for weight loss before children and adults rush out the door is breakfast recipes for kids a bowl of sugar-coated cereal. An alternate version is a pastry and a cup of Tips for Healthy Eating coffee. These foods are highly processed and Breakfast and Brunch Cookbook high in sugar. They fill the void and give you a healthy indian breakfast recipe quick flash of energy, but the effect is short lived. By healthy brekfast foods for girls mid-morning, you're tired wrap sandwich recipes and hungry. Not only are you Real Food for Healthy Kids consuming empty calories, but you're also increasing your risk of diabetes healthy breakfast menus kids and obesity.Eating regular meals — especially breakfast — every day is a good health habit. Breakfast kick-starts your metabolism, healthy snack foods kids provides fuel for your healthy snacks kids mind, and healthy breakfast fruits for kids cuts down on mid morning snacking. Most snack foods are breakfast and brunch cookbook morning high in calories, fat, sugar, easy breakfast casserole and salt, and low in nutrients. This is probably one reason why pictures of healthy food breakfast skippers tend to weigh more healthy food habits.

  Re: javascript, get the color assigned by class  breakfastfood09 at 05:58 on Monday, August 01, 2011
 

A century ago, American farmers healthy breakfast and city-dwellers alike piled breakfast low calorie diet plan plates high with meat, potatoes, gravy, eggs, bread, and healthy breakfast ideas/strong> sometimes pastries. Not much has eggs breakfast recipe changed.A 21st century leisurely breakfast often healthy breakfast foods consists of sausage or bacon, eggs, fried potatoes, gravy, healthy breakfast cookie recipe and waffles or pancakes smothered healthy breakfast cereal choices in butter and syrup or topped with healthy breakfast recipes sweetened fruit compote low calorie breakfast recipes and whipped cream.This breakfast is high in saturated fat and low in vitamins and healthy breakfast diet for kids other important nutrients. People who engage average breakfast cereal choices in regular hard work similar to healthy breakfast choices our ancestors, like the Amish, might get away with diet breakfast recipes eating that diet, but the rest of healthy eating tips America is at healthy breakfast dishes for kids increased risk of obesity and chronic diseases, such as cancer and diabetes.Another typical breakfast hurriedly gobbled down healthy recipes for weight loss before children and adults rush out the door is breakfast recipes for kids a bowl of sugar-coated cereal. An alternate version is a pastry and a cup of Tips for Healthy Eating coffee. These foods are highly processed and Breakfast and Brunch Cookbook high in sugar. They fill the void and give you a healthy indian breakfast recipe quick flash of energy, but the effect is short lived. By healthy brekfast foods for girls mid-morning, you're tired wrap sandwich recipes and hungry. Not only are you Real Food for Healthy Kids consuming empty calories, but you're also increasing your risk of diabetes healthy breakfast menus kids and obesity.Eating regular meals — especially breakfast — every day is a good health habit. Breakfast kick-starts your metabolism, healthy snack foods kids provides fuel for your healthy snacks kids mind, and healthy breakfast fruits for kids cuts down on mid morning snacking. Most snack foods are breakfast and brunch cookbook morning high in calories, fat, sugar, easy breakfast casserole and salt, and low in nutrients. This is probably one reason why pictures of healthy food breakfast skippers tend to weigh more healthy food habits.

  Re: javascript, get the color assigned by class  clark40 at 10:18 on Monday, August 01, 2011
 

I hope you can give several advices to me, because your knowledge is great, it can help many students to get great score in every task or project. If you don’t mind, I will contact you to make short discussion for my project.testking \ pass4sure mcitp | pass4sure mcts | pass4sure mcdba | pass4sure mcdst \ pass4sure microsoft certification | pass4sure windows 7 | pass4sure mcp

  nice  danaray79 at 18:25 on Tuesday, August 02, 2011
 

I must appreciate you for the information you have shared.I find this information very useful and it has considerably saved my time.thanks

Buy Articles | Life Experience Degree | bachelor degree | Sample Essays








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: Cookies - i have a hard time with them
•  Re: Date Picker - help wanted
•  Re: Currency Converter Help
•  Re: This is probably a simple fix, but I can not seem to get it .
•  Re: How to uplaod a file in asp.net using the input(file) tool,
•  Re: Problem with repainting a canvas.
•  Re: Creating Dynamic Menu Structure
•  Re: Random Image and Zoom Script
•  Re: Convert WAV in MP3


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2011