아래에 표시된 html 코드 (javascript 포함)는 IE를 제외한 모든 브라우저에서 작동합니다.Explorer에서 getElementById와 관련된 JS 문제
나는 IE가 getElementById 및 ID 코드를 처리하고 싶지 않다는 것을 최근에 알게되었습니다.
나에게 조언 해줄 누군가가 친절한가요? 또 다른 방법으로 작동 시키거나 해결 코드가 있습니까? 사전에
감사합니다, 에릭
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<title>test</title>
<script type="text/javascript">
<!--
var color = new Object();
color["100"] = new Array("300", "400");
color["200"] = new Array("100", "300", "400");
color["300"] = new Array("100", "200");
color["400"] = new Array("200");
var colors = new Array("related");
function on(id)
{
for (var i=0; i<color[id].length; i++)
{
var el = document.getElementById("index_"+color[id][i]);
if (el)
{
el.setAttribute("class", colors[i%1]);
}
}
}
function off(id)
{
for (var i=0; i<color[id].length; i++)
{
var el = document.getElementById("index_"+color[id][i]);
if (el)
{
el.removeAttribute("class");
}
}
}
//-->
</script>
<style type="text/css">
<!--
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
line-height: 18px;
color: #000000;
text-decoration: none;
}
a:link,
a:visited {
color: #000000;
text-decoration: none;
}
a:hover,
a:active {
color: #FF0000;
text-decoration: underline;
}
a.related {
color: #FF0000;
text-decoration: none;
}
-->
</style>
</head>
<body>
<a href="#" id="index_100" name="index_100" onMouseOver="on(100)" onMouseOut="off(100)">aaa</a><br />
<br />
<a href="#" id="index_200" name="index_200" onMouseOver="on(200)" onMouseOut="off(200)">bbb</a><br />
<br />
<a href="#" id="index_300" name="index_300" onMouseOver="on(300)" onMouseOut="off(300)">ccc</a><br />
<br />
<a href="#" id="index_400" name="index_400" onMouseOver="on(400)" onMouseOut="off(400)">ddd</a>
</body>
</html>
네, 고마워요. 문제가 해결되었습니다. –