469,329 Members | 1,364 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,329 developers. It's quick & easy.

bgColor error. What am I doing wrong?


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
4 1497
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
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
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
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.

Similar topics

15 posts views Thread by @sh | last post: by
7 posts views Thread by Brett | last post: by
6 posts views Thread by acord | last post: by
6 posts views Thread by GaryDean | last post: by
12 posts views Thread by GaryDean | last post: by
5 posts views Thread by Don Lancaster | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by Purva khokhar | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.