[問題] JavaScript在IE上與Mozilla上跑的結果不一

看板Web_Design作者 (嘿嘿~)時間18年前 (2006/05/06 16:06), 編輯推噓4(400)
留言4則, 3人參與, 最新討論串1/1
在IE上 我用alert(a.style.backgroundColor)測試 跑出#ffff66 or ##ccff99 但 在Mozilla上 用alert(a.style.backgroundColor)測試 卻跑出rgb(255,255,102) or rgb(204,255,153) 這樣在Mozilla上就達不到我所要的效果了 請問要怎麼改才行呢??? <script language="javascript"> var clClick = '#CCFF99'; // color click var clMove = '#FFFF66'; // color move var count = 0; //按下去會變色 function clickColor(a){ alert(a.style.backgroundColor); //click1...按第一次...變色 if( a.style.backgroundColor.toUpperCase()!=clClick ){ a.style.backgroundColor = clClick; document.getElementById("AAA").innerHTML = ++count ; } //click2...按第二次...變回去(MouseOver) else if( a.style.backgroundColor.toUpperCase()!=clMove ){ a.style.backgroundColor = clMove; document.getElementById("AAA").innerHTML = --count ; } } </script> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 219.81.178.219 ※ 編輯: Falldog 來自: 219.81.178.219 (05/06 16:13)

05/06 16:43, , 1F
不要用字串比對...把它當成數值:p
05/06 16:43, 1F

05/06 17:51, , 2F
當成數值? 請問該怎麼做啊? 感謝您~
05/06 17:51, 2F

05/06 18:22, , 3F
16進位的數值???
05/06 18:22, 3F

05/07 07:33, , 4F
我試過了耶~ 還是不行...
05/07 07:33, 4F
文章代碼(AID): #14N5aKAI (Web_Design)