By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,934 Members | 1,527 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,934 IT Pros & Developers. It's quick & easy.

bgColor error. What am I doing wrong?

P: n/a

I set up a table...

<table
bgcolor=#FF9966
name=msSel
onmouseover="msSel.bgColor='#FFCC66'"
onmouseout="differentFunction ();"
<tr><td>stuff</tr></td>
>
mouseout is eventully supposed to do several things,
only one of which is to reset the single cell table
color. A shortened function would be

function differentFunction (){

msSel.bgColor="#FF9966" ;
// other stuff here
} ;

on mouseout, a msSEL not found error is returned from
inside differentFunction.

substituting "this.bgColor" neither returns an error
nor changes the color. There are other reasons later
for not using "this" instead of specific names.

Why the error?
What is the correction or workaround?


--
Many thanks,

Don Lancaster voice phone: (928)428-4073
Synergetics 3860 West First Street Box 809 Thatcher, AZ 85552
rss: http://www.tinaja.com/whtnu.xml email: do*@tinaja.com

Please visit my GURU's LAIR web site at http://www.tinaja.com
Apr 24 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Don Lancaster said the following on 4/24/2007 11:58 AM:
>
I set up a table...

<table
bgcolor=#FF9966
name=msSel
onmouseover="msSel.bgColor='#FFCC66'"
onmouseout="differentFunction ();"
<tr><td>stuff</tr></td>
>

mouseout is eventully supposed to do several things,
only one of which is to reset the single cell table
color. A shortened function would be

function differentFunction (){

msSel.bgColor="#FF9966" ;
// other stuff here
} ;

on mouseout, a msSEL not found error is returned from
inside differentFunction.
<URL: http://jibbering.com/faq/index.html#FAQ4_41>

onmouseout="differentFunction(this)"

function differentFunction(elem){
elem.bgColor="#FF9966"
}

But, why do you quote in your function (which you should) but not in
your HTML (which you should) while using deprecated HTML3.2 bgcolor
(which you shouldn't). CSS is your friend.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 24 '07 #2

P: n/a
On Apr 24, 11:58 am, Don Lancaster <d...@tinaja.comwrote:
function differentFunction (){
msSel.bgColor="#FF9966" ;
this.style.backgroundColor = "#FF9966";

Kev

Apr 25 '07 #3

P: n/a
Kevin Darling said the following on 4/25/2007 6:36 PM:
On Apr 24, 11:58 am, Don Lancaster <d...@tinaja.comwrote:
> function differentFunction (){
msSel.bgColor="#FF9966" ;

this.style.backgroundColor = "#FF9966";
In that scenario? "this" doesn't refer to what you think it does. Test it :)

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 25 '07 #4

P: n/a
On Apr 25, 6:41 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
Kevin Darling said the following on 4/25/2007 6:36 PM:
On Apr 24, 11:58 am, Don Lancaster <d...@tinaja.comwrote:
function differentFunction (){
msSel.bgColor="#FF9966" ;
this.style.backgroundColor = "#FF9966";

In that scenario? "this" doesn't refer to what you think it does. Test it :)
D'oh !! Yes, I know that. I posted very quickly before dinner and
mixed up editing two different answers. Shame on me!

Thanks for pointing it out :-)

Kev

Apr 26 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.