来自'this'的bgcolor [英] bgcolor from a 'this'

查看:79
本文介绍了来自'this'的bgcolor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试这样做,但它不起作用......?!我的目标是更改用户已翻转的单元格的

bgcolor,然后我将复制

将其作为OnMouseOut进行更改。 br />

-----------------------------

< script language =" JavaScript">

<! -

函数Ash_TopNavRollovers(TheObject); {$ / $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ < / script>

-----------------------------


和身体......


--------------------------- -

< td width =" 91"对齐= QUOT;中心" valign =" middle">< a href ="#"

class =" TopNavTextNormal" OnMouseover =" Ash_TopNavRollovers(this);"> Button

Text Here< / a>< / td>

--------- --------------------


感谢您的帮助!

解决方案

@sh写道:

< script language =" JavaScript">


使用

type =" text / javascript"

属性而不是已弃用的语言属性。


TheObject.bgcolor ="#000099;" ;;


使用CSS代替:

TheObject.style.backgroundColor ="#000099;" ;;


class =" TopNavTextNormal"




也许这个类定义它自己的背景颜色并更改HTML

元素bgcolor属性虽然没有效果。


Daniel


@sh写道:

试图这样做,但它不起作用......?!我的目标是更改用户翻过的单元格的
bgcolor,然后我会将其复制为OnMouseOut以将其更改回来。

- ----------------------------
< script language =" JavaScript">
<! -
函数Ash_TopNavRollovers(TheObject); {
TheObject.bgcolor ="#000099;";
}
- >
< / script>
------- ----------------------


< script type =" text / javascript">

函数Ash_TopNavRollovers(theObject){

if(theObject&& theObject.style){

theObject.style.backgroundColor ="#000099" ;

}

}

< / script>


< style type =" ; text / css">

a {display:block;}

< / style>


Mick

AND THE BODY ......

-----------------------------
< td width =" 91"对齐= QUOT;中心" valign =" middle">< a href ="#"
class =" TopNavTextNormal" OnMouseover =" Ash_TopNavRollovers(this);"> Button
Text Here< / a>< / td>
----------------- ------------

感谢您的帮助!



Mick White写道:

@sh写道:

试图这样做,但它不起作用......?!我的目标是更改用户翻过的单元格的
bgcolor,然后我会将其复制为OnMouseOut以将其更改回来。

- ----------------------------
< script language =" JavaScript">
<! -
函数Ash_TopNavRollovers(TheObject); {
TheObject.bgcolor ="#000099;";
}
- >
< / script>
------- ----------------------




看作''A''是IE允许CSS''悬停''的* only *元素(并且

即使它必须具有href属性),为什么不使用它?根本不需要JS

.


负责人:


< style type =" text / css" ;>

#special a {

display:block;

}

#special a:hover {

背景颜色:#000099;

}

#special td {

宽度:5em;

text-align:center;

}

< / style>

身体:


< table id =" special">

< tr>

< td valign =" middle">< a href ="#">按钮文字在这里< / a>< / td>

< / tr>

< / table>

< a href ="#">普通A< / a>


-

Rob


Trying to do this, but its not working...?! My aim being to change the
bgcolor of the cell upon which the user has rolled over, I''ll then replicate
this as an OnMouseOut to change it back.

-----------------------------
<script language="JavaScript">
<!--
function Ash_TopNavRollovers(TheObject); {
TheObject.bgcolor="#000099;";
}
-->
</script>
-----------------------------

AND IN THE BODY...

-----------------------------
<td width="91" align="center" valign="middle"><a href="#"
class="TopNavTextNormal" OnMouseover="Ash_TopNavRollovers(this);">Button
Text Here</a></td>
-----------------------------

Appreciate your help!

解决方案

@sh wrote:

<script language="JavaScript">
use the
type="text/javascript"
attribute instead of the deprecated language attribute.

TheObject.bgcolor="#000099;";
use CSS instead:

TheObject.style.backgroundColor="#000099;";

class="TopNavTextNormal"



Maybe this class defines it''s own background-color and changing the HTML
elements bgcolor attribute doesn''t have an effect though.

Daniel


@sh wrote:

Trying to do this, but its not working...?! My aim being to change the
bgcolor of the cell upon which the user has rolled over, I''ll then replicate
this as an OnMouseOut to change it back.

-----------------------------
<script language="JavaScript">
<!--
function Ash_TopNavRollovers(TheObject); {
TheObject.bgcolor="#000099;";
}
-->
</script>
-----------------------------
<script type="text/javascript">
function Ash_TopNavRollovers(theObject){
if(theObject && theObject.style){
theObject.style.backgroundColor="#000099";
}
}
</script>

<style type="text/css">
a {display: block;}
</style>

Mick

AND IN THE BODY...

-----------------------------
<td width="91" align="center" valign="middle"><a href="#"
class="TopNavTextNormal" OnMouseover="Ash_TopNavRollovers(this);">Button
Text Here</a></td>
-----------------------------

Appreciate your help!



Mick White wrote:

@sh wrote:

Trying to do this, but its not working...?! My aim being to change the
bgcolor of the cell upon which the user has rolled over, I''ll then
replicate this as an OnMouseOut to change it back.

-----------------------------
<script language="JavaScript">
<!--
function Ash_TopNavRollovers(TheObject); {
TheObject.bgcolor="#000099;";
}
-->
</script>
-----------------------------



Seeing as ''A'' is the *only* element that IE allows CSS ''hover'' on (and
even then it must have a href attribute), why not use that? No JS
required at all.

Head:

<style type="text/css">
#special a {
display: block;
}
#special a:hover {
background-color:#000099;
}
#special td {
width: 5em;
text-align: center;
}
</style>
Body:

<table id="special">
<tr>
<td valign="middle"><a href="#">Button Text Here</a></td>
</tr>
</table>
<a href="#">Ordinary A</a>

--
Rob


这篇关于来自'this'的bgcolor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆