webForumDet fria alternativet
Logga in / Bli medlem

Problem med IE

JavaScript

1 svar · 147 visningar · startad av Cactuz

Medlem sedan okt. 2001670 inlägg
Trådstart#1

Den här koden funkar i Mozilla Firebird.
Men det buggar i IE. Cellen får #C0C0C0 färgen men sen när den ska byta tillbaka (onmouseout) vill den inte.

<td class="'.$bg.'" OnClick="fadeclick(this, \''.$bg.'\')" OnMouseOver="fade(this, \''.$bg.'\')" OnMouseOut="fade(this, \''.$bg.'\')">
function fade(obj, cl)
{
	if(obj.style.backgroundColor != 'rgb(170, 201, 235)')
	{
	if(obj.style.backgroundColor == 'rgb(192, 192, 192)')
	{
		if(cl == 'puncon1')
		{
			obj.style.backgroundColor='#DEDFDF';
		}else{
			obj.style.backgroundColor='#EEEEEE';
		}
	}else{
		obj.style.backgroundColor = '#C0C0C0';
	}
	}	
}
function fadeclick(obj, cl)
{
	if(obj.style.backgroundColor == 'rgb(170, 201, 235)')
	{
		obj.style.backgroundColor='#C0C0C0';
	}else{
		obj.style.backgroundColor = '#AAC9EB';
	}	
}
Medlem sedan okt. 2001670 inlägg
#2

Problemet var att obj.style.backgroundColor i IE stod i HEX.

265 ms totalt · 4 externa anrop · v20260731065814-full.51f67c91
128 ms — deklarationer (db)
0 ms — hämta statistik (cache)
134 ms — hämta tråd, inlägg och bilagor (db)
124 ms — ändringar (db)