익스에서는 잘되는데 크롭에서는 안되요 ㅠ_ㅠ 정보
익스에서는 잘되는데 크롭에서는 안되요 ㅠ_ㅠ
본문
너무도 급한 마음에 다시 올려 봅니다.
<table border="1" bordercolor="#00FF00">
<tr>
<td height="50" width="50" align="center" style="cursor:hand; background-color:#ffff00" id="a1" onClick="sel()">No.1</td>
<td height="50" width="50" align="center" style="cursor:hand; background-color:#ffff00" id="a2" onClick="sel()">No.2</td>
</tr>
<tr>
<td height="50" width="50" align="center" style="cursor:hand; background-color:#ffff00" id="a3" onClick="sel()">No.3</td>
<td height="50" width="50" align="center" style="cursor:hand; background-color:#FFFF00" id="a4" onClick="sel()">No.4</td>
</tr>
</table>
<script type="text/javascript">
function sel()
{
var tt=document.getElementById(event.srcElement.id);
if (tt.style.backgroundColor=="#ffff00")
{
tt.style.backgroundColor="#000000";
}else{
tt.style.backgroundColor="#ffff00";
}
}
</script>
위 코드는 익스에서는 잘 돌아 가는데.. 그외에는 먹통이내요..
고수님들 가르쳐 주세요...꾸뻑
style.backgroundColor <-- 이넘이 뭐시 문제인듯 한데..
익스는 리턴값이 '#000000' 이런식인데
크롬은 'rgb(0,0,0)' 이런식이군요... 음..
<table border="1" bordercolor="#00FF00">
<tr>
<td height="50" width="50" align="center" style="cursor:hand; background-color:#ffff00" id="a1" onClick="sel()">No.1</td>
<td height="50" width="50" align="center" style="cursor:hand; background-color:#ffff00" id="a2" onClick="sel()">No.2</td>
</tr>
<tr>
<td height="50" width="50" align="center" style="cursor:hand; background-color:#ffff00" id="a3" onClick="sel()">No.3</td>
<td height="50" width="50" align="center" style="cursor:hand; background-color:#FFFF00" id="a4" onClick="sel()">No.4</td>
</tr>
</table>
<script type="text/javascript">
function sel()
{
var tt=document.getElementById(event.srcElement.id);
if (tt.style.backgroundColor=="#ffff00")
{
tt.style.backgroundColor="#000000";
}else{
tt.style.backgroundColor="#ffff00";
}
}
</script>
위 코드는 익스에서는 잘 돌아 가는데.. 그외에는 먹통이내요..
고수님들 가르쳐 주세요...꾸뻑
style.backgroundColor <-- 이넘이 뭐시 문제인듯 한데..
익스는 리턴값이 '#000000' 이런식인데
크롬은 'rgb(0,0,0)' 이런식이군요... 음..
댓글 전체
color 값도 문제지만 event를 받는 방식도 다릅니다
cursor:hand 란 속성도 ie용 입니다. 표준은 cursor:pointer
event를 ie 냐 아니냐에 따라 다르게 처리하는 방식으로 하는 것 보다
<td onclick="sel(this)..................>이렇게 한 후 아래와 같이
function sel(tt){
color=tt.style.backgroundColor;
color=color.replace(/ /g,''); // 이게 있어야하는 이유는? 주석처리 후 해보세요
tt.style.backgroundColor=color=="rgb(0,0,0)"?"rgb(255,255,0)":"rgb(0,0,0)"; //잘됨
// tt.style.backgroundColor=color=="yellow"?"black":"yellow"; // 잘됨
//tt.style.backgroundColor=color=="rgb(0,0,0)"?"#FFFF00":"#000000"; // ie 안됨
//tt.style.backgroundColor=color=="#000000"?"#FFFF00":"#000000"; // 크롬 안됨
}
cursor:hand 란 속성도 ie용 입니다. 표준은 cursor:pointer
event를 ie 냐 아니냐에 따라 다르게 처리하는 방식으로 하는 것 보다
<td onclick="sel(this)..................>이렇게 한 후 아래와 같이
function sel(tt){
color=tt.style.backgroundColor;
color=color.replace(/ /g,''); // 이게 있어야하는 이유는? 주석처리 후 해보세요
tt.style.backgroundColor=color=="rgb(0,0,0)"?"rgb(255,255,0)":"rgb(0,0,0)"; //잘됨
// tt.style.backgroundColor=color=="yellow"?"black":"yellow"; // 잘됨
//tt.style.backgroundColor=color=="rgb(0,0,0)"?"#FFFF00":"#000000"; // ie 안됨
//tt.style.backgroundColor=color=="#000000"?"#FFFF00":"#000000"; // 크롬 안됨
}

우왓 답변 감사합니다. 적용 시켜보고 오겠습니다 ㅠ_ㅠ 너무 감사합니다.

감사합니다.하하하하하...
근데 죄송합니다만.....
color=color.replace(/ /g,'');
tt.style.backgroundColor=color=="rgb(0,0,0)"?"rgb(255,255,0)":"rgb(0,0,0)"; //잘됨
이거 설명좀 부탁드려도 되겠습니까.. 잘 이해가 가지 않아서요..
부탁드리겠습니다 ...꾸뻑..
근데 죄송합니다만.....
color=color.replace(/ /g,'');
tt.style.backgroundColor=color=="rgb(0,0,0)"?"rgb(255,255,0)":"rgb(0,0,0)"; //잘됨
이거 설명좀 부탁드려도 되겠습니까.. 잘 이해가 가지 않아서요..
부탁드리겠습니다 ...꾸뻑..

스페이스를 null값으로???
음... 출력해 보면.. 스페이스값이 없는데...
왜 color=color.replace(/ /g,''); 이걸 안쓰면 안될까요? 으아.. 궁금...
누가 설명좀...ㅠ_ㅠ 프리즈..
음... 출력해 보면.. 스페이스값이 없는데...
왜 color=color.replace(/ /g,''); 이걸 안쓰면 안될까요? 으아.. 궁금...
누가 설명좀...ㅠ_ㅠ 프리즈..