Javascript &引用;“未找到成员”;IE6中的错误:from.style edit或getElementById或。。。?

Javascript &引用;“未找到成员”;IE6中的错误:from.style edit或getElementById或。。。?,javascript,html,internet-explorer,Javascript,Html,Internet Explorer,我自愿为一个小组织开发这个脚本(作为我编程自我培训的一部分)。它随机选择房间中的一个座位(花费几秒钟让观众猜测选择了哪个座位)。因为我使用Mac,所以我主要使用Firefox进行测试,在Firefox中它就像一个魔咒。他们房间里的电脑在Windows XP上运行Internet Explorer 6(他们必须在本地文件中启用活动内容) 他们给我打电话通知我有错误,根据他们提供的信息,有罪的一行是RowNumberDisplay.style=“color:#FF0000”或var RowNumbe

我自愿为一个小组织开发这个脚本(作为我编程自我培训的一部分)。它随机选择房间中的一个座位(花费几秒钟让观众猜测选择了哪个座位)。因为我使用Mac,所以我主要使用Firefox进行测试,在Firefox中它就像一个魔咒。他们房间里的电脑在Windows XP上运行Internet Explorer 6(他们必须在本地文件中启用活动内容)

他们给我打电话通知我有错误,根据他们提供的信息,有罪的一行是
RowNumberDisplay.style=“color:#FF0000”
var RowNumberDisplay=document.getElementById(“RowNumber”)。在Google和Stack Overflow上快速搜索IE6中的getElementById和.style问题都没有结果(一个常见的问题是由于名称属性导致的错误匹配,但所讨论的div没有名称属性)。提前感谢您提供的任何有助于识别和解决此错误的答案

<!doctype html>
<html>
    <head>
        <title>The Lucky Person</title>
            <style type="text/css">
            input#SelectLuckyPerson
            {
                height: 150px;
                font-size: 60px;
            }
            p#RowDetails, p#SeatDetails, div#RowNumber, div#SeatNumber
            {
                font-size: 100px;
                display: inline;
            }
            div#RowNumber, div#SeatNumber
            {
                color: #0000FF;
            }
            </style>
    </head>
    <body>
        <div id="LuckyPersonIs"><input type="button" id="SelectLuckyPerson" value="And the lucky person is..." onClick="GetResults();"></div>
        <p id="RowDetails">Row number: <div id="RowNumber">0</div></p>
        <p id="SeatDetails">Seat number: <div id="SeatNumber">0</div></p>
        <script>
            var MinRow = 2;
            var MaxRow = 8;
            var SeatsInRow = new Array();
            SeatsInRow[1] = 25;
            SeatsInRow[2] = 25;
            SeatsInRow[3] = 27;
            SeatsInRow[4] = 27;
            SeatsInRow[5] = 27;
            SeatsInRow[6] = 27;
            SeatsInRow[7] = 29;
            SeatsInRow[8] = 31;
            SeatsInRow[9] = 31;
            SeatsInRow[10] = 31;
            SeatsInRow[11] = 31;
            SeatsInRow[12] = 33;
            SeatsInRow[13] = 33;
            SeatsInRow[14] = 33;
            var ShuffleSpeed = 200;
            var RowNumberDisplay = document.getElementById("RowNumber");
            var SeatNumberDisplay = document.getElementById("SeatNumber");
            var ChosenRow, ChosenSeat
            function GetResults()
            {
                var IsRunning = CheckStatus();
                if (IsRunning)
                {
                    ChosenRow = ChooseRow();
                    ChosenSeat = ChooseSeat();
                    RowNumberDisplay.style = "color: #FF0000";
                    SeatNumberDisplay.style = "color: #FF0000";
                    ShowRowResult = window.setInterval("TryRowResult()", ShuffleSpeed);
                    if (DelaySeats == false)
                    {
                        ShowSeatResult = window.setInterval("TrySeatResult()", ShuffleSpeed);
                    }
                }
            }
            function ChooseRow()
            {
                return Math.floor(Math.random() * (MaxRow - MinRow)) + MinRow;
            }
            function ChooseSeat()
            {
                return Math.ceil(Math.random() * SeatsInRow[ChosenRow]);
            }
            function TryRowResult()
            {
                TryRow = ChooseRow();
                RowNumberDisplay.innerHTML = TryRow;
                if (TryRow == ChosenRow)
                {
                    window.clearInterval(ShowRowResult);
                    document.getElementById("RowNumber").style = "color: #0000FF";
                    if (DelaySeats == true)
                    {
                        ShowSeatResult = window.setInterval("TrySeatResult()", ShuffleSpeed);
                    }
                }
            }
            function TrySeatResult()
            {
                TrySeat = ChooseSeat();
                SeatNumberDisplay.innerHTML = TrySeat;
                if (TrySeat == ChosenSeat)
                {
                    window.clearInterval(ShowSeatResult);
                    document.getElementById("SeatNumber").style = "color: #0000FF";
                }
            }
            function CheckStatus()
            {
                if (RowNumberDisplay.style.color == "rgb(255, 0, 0)" || SeatNumberDisplay.style.color == "rgb(255, 0, 0)")
                {
                    return false;
                }
                return true;
            }
            </script>
    </body>
</html>

幸运儿
输入#选择LuckyPerson
{
高度:150像素;
字体大小:60px;
}
p#行详细信息,p#SeatDetails,div#RowNumber,div#SeatNumber
{
字体大小:100px;
显示:内联;
}
分区行号,分区座位号
{
颜色:#0000FF;
}

行号:0

座位号:0

var MinRow=2; var MaxRow=8; var seatinsrow=新数组(); Seatsirow[1]=25; 西斯罗[2]=25; 西斯罗[3]=27; Seatsirow[4]=27; 西斯罗[5]=27; 西斯罗[6]=27; 西斯罗[7]=29; 西斯罗[8]=31; 西斯罗[9]=31; Seatsirow[10]=31; 西斯罗[11]=31; 西斯罗[12]=33; 西斯罗[13]=33; 西斯罗[14]=33; var ShuffleSpeed=200; var RowNumberDisplay=document.getElementById(“RowNumber”); var SeatNumberDisplay=document.getElementById(“SeatNumber”); var ChosenRow,ChosenSeat 函数GetResults() { var IsRunning=CheckStatus(); 如果(正在运行) { ChosenRow=ChooseRow(); ChosenSeat=ChooseSeat(); RowNumberDisplay.style=“颜色:#FF0000”; SeatNumberDisplay.style=“颜色:#FF0000”; ShowRowResult=window.setInterval(“TryRowResult()”,ShuffleSpeed); if(DelaySeats==false) { ShowSeatResult=window.setInterval(“TrySeatResult()”,ShuffleSpeed); } } } 函数选择器w() { 返回Math.floor(Math.random()*(MaxRow-MinRow))+MinRow; } 函数选择器seat() { 返回Math.ceil(Math.random()*SeatRow[ChosenRow]); } 函数TryRowResult() { TryRow=ChooseRow(); RowNumberDisplay.innerHTML=TryRow; if(TryRow==ChosenRow) { 窗口。清除间隔(ShowRowResult); document.getElementById(“RowNumber”).style=“color:#0000FF”; if(DelaySeats==true) { ShowSeatResult=window.setInterval(“TrySeatResult()”,ShuffleSpeed); } } } 函数TrySeatResult() { TrySeat=ChooseSeat(); SeatNumberDisplay.innerHTML=TrySeat; if(TrySeat==ChosenSeat) { 窗口清除间隔(ShowSeatResult); document.getElementById(“SeatNumber”).style=“color:#0000FF”; } } 函数CheckStatus() { 如果(RowNumberDisplay.style.color==“rgb(255,0,0)”| | SeatNumberDisplay.style.color==“rgb(255,0,0)”) { 返回false; } 返回true; }
元素的
样式
属性是对象,而不是字符串。要像CSS属性一样为其指定文本,应将其指定给
元素.style.cssText
,这将为您解析字符串,并作为定义多个样式的快捷方式

但是,在这种情况下,您可以使用:

ChosenRow.style.color = ChosenSeat.style.color = "#f00";

元素的
样式
属性是对象,而不是字符串。要像CSS属性一样为其指定文本,应将其指定给
元素.style.cssText
,这将为您解析字符串,并作为定义多个样式的快捷方式

但是,在这种情况下,您可以使用:

ChosenRow.style.color = ChosenSeat.style.color = "#f00";

你知道,如果我在做某件事,而我为之制作的人坚持仍在使用IE6?我会把项目说明书扔给他们然后离开。像这样的人不值得我们开发者牺牲时间,仅仅因为他们不能被纵火点击“更新”按钮。WinXP至少可以获得IE8,而且肯定是Chrome或FF。或者这不是他们的选择吗?他们正在升级程序的中间,但还没有到达那个房间的电脑。事实证明IE8也给出了同样的错误信息。你知道,如果我在做一些事情,而我为之制作的人坚持仍然使用IE6?我会把项目说明书扔给他们然后离开。这样的人不值得我们开发人员花那么多时间