English 中文(简体)
为什么Change坠毁因特网探索者7?
原标题:Why does onChange crash Internet Explorer 7?

我们刚刚释放了一个网上商店。

On this page the selectboxes crashes Internet Explorer 7 on some computers. Never on my computer. Does anybody knows why?

Live link: http://velour.se/collection/women/tops/eloise A. 更新: turns out that the first like I posted did not crash. But the following does: http://velour.se/collection/women/outerwear/irina

Screendump:

<>原件:

<select id="sizeDD" onchange="javascript:SizeChange(this);"></select>

//Internet Explorer problem.
function SizeChange(e){
    DrawAmountDD(GetAmountById(e.value));
}

这里,我认为可能涉及法典的一部分:

    function DrawAmountDD(maxAmount){
        /*var max = parseInt(maxAmount) > parseInt(maxShowAmount) ? maxShowAmount : maxAmount;
        var html = "";
        for(var i=1; i <= max; i++){
            html += "<option value= " + i + " >" + i + "</option>";
        }
        $("#amountDD").html(html);*/

        var max = parseInt(maxAmount) > parseInt(maxShowAmount) ? maxShowAmount : maxAmount;
        var ddlAmount = document.getElementById("amountDD");
        ddlAmount.length=max;

        for(var a=1; a <= max; a++){
            ddlAmount.options[a-1].value = a;
            ddlAmount.options[a-1].text = a;
        }
    }

第2版

<select id="sizeDD"></select>
<select id="amountDD"></select>

<script type="text/javascript">
    var maxShowAmount =  5 ;
    var colorSizeArr =
      { "colSize":
        [
            { "color": "Black/Offwhite",
              "specificId": "2",
              "size": "XS",
              "amount": "1" }
        ]
      };

    colorSizeArr.colSize.push(
      { "color": "Black/Offwhite",
        "specificId": "13",
        "size": "S",
        "amount": "2" });

    $(document).ready(function () {
        var selectSizeDD = document.getElementById( sizeDD );
        selectSizeDD.onchange = function () { sizeChange(selectSizeDD); };
    });

    function sizeChange(e) {
        DrawAmountDD(GetAmountById(e.value));
    }

    function GetAmountById(specificId) {
        for (var i = 0; i < colorSizeArr.colSize.length; i++) {
            if (colorSizeArr.colSize[i].specificId == specificId) {
                return colorSizeArr.colSize[i].amount;
            }
        }
        return 1;
    }

    function DrawAmountDD(maxAmount) {
        var max = parseInt(maxAmount) > parseInt(maxShowAmount) ? maxShowAmount : maxAmount;
        var html = "";
        for (var i = 1; i <= max; i++) {
            html += "<option value= " + i + " >" + i + "</option>";
        }
        $("#amountDD").html(html);

    }
</script>

A. 更新

我没有夸张为什么因特网探索者7在一些电脑上坠毁。 无论怎样,上述法典都与它毫不相干。 更为简单。 浏览器在点击只有一个选择的选箱时坠毁。 与此类似:

<select id="amountDD">
<option value="1">1</option>
</select>

我发现,这一联系有一些动因,其中说,单一选择也应有某些属性,但对我们来说,这似乎有错。

最佳回答
问题回答

I hope by "crash" you mean "the JavaScript doesn t work", not "Internet Explorer crashes." If it s just the page, you can usually see the error by clicking "error on page" in the status bar.
Also, try some classic JavaScript debugging - comment out blocks of the function one at a time until you find the block that crashes it, then narrow it down to the line.





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签