zoukankan      html  css  js  c++  java
  • 跳到IE9的一个坑里了(枚举 JavaScript 属性)

    有一段Json如下

    [{"SaleName_ID":"0","SaleName":"","28":"45","14":"20","13":"40","8":"50","SSD_ChargesType":"1","SSD_SaleSetType":"0"},
    {"SaleName_ID":"1","SaleName":"SeleA","28":"1","14":"1","13":"1","8":"1","SSD_ChargesType":"2","SSD_SaleSetType":"1"},
    {"SaleName_ID":"2","SaleName":"SeleB","28":"2","14":"2","13":"2","8":"2","SSD_ChargesType":"2","SSD_SaleSetType":"1"},
    {"SaleName_ID":"3","SaleName":"SeleC","28":"3","14":"3","13":"3","8":"3","SSD_ChargesType":"2","SSD_SaleSetType":"1"},
    {"SaleName_ID":"4","SaleName":"SeleD","28":"4","14":"4","13":"4","8":"4","SSD_ChargesType":"2","SSD_SaleSetType":"1"}]

    因为中间的列数有可能多也有可能少,不知道列名,所以只能用for in的办法来解决

    JS代码如下

    for (var Row in SetSaleDetailJson) {
                    for (var key in SetSaleDetailJson[Row])
                    {
                        
                        $("#zw").append(key + "=" + SetSaleDetailJson[Row][key] + ",");
                    }
                    $("#zw").append("<br>");
                }

    在IE8中firefox12.0中结果如下(是我想要的结果)

    SaleName_ID=0,SaleName=,28=45,14=20,13=40,8=50,SSD_ChargesType=1,SSD_SaleSetType=0,
    SaleName_ID=1,SaleName=SeleA,28=1,14=1,13=1,8=1,SSD_ChargesType=2,SSD_SaleSetType=1,
    SaleName_ID=2,SaleName=SeleB,28=2,14=2,13=2,8=2,SSD_ChargesType=2,SSD_SaleSetType=1,
    SaleName_ID=3,SaleName=SaleC,28=3,14=3,13=3,8=3,SSD_ChargesType=2,SSD_SaleSetType=1,
    SaleName_ID=4,SaleName=SaleD,28=4,14=4,13=4,8=4,SSD_ChargesType=2,SSD_SaleSetType=1,

    但是到了IE9,IE10中就变成如下的结果了

    8=50,13=40,14=20,28=45,SaleName_ID=0,SaleName=,SSD_ChargesType=1,SSD_SaleSetType=0,
    8=1,13=1,14=1,28=1,SaleName_ID=1,SaleName=SeleA,SSD_ChargesType=2,SSD_SaleSetType=1,
    8=2,13=2,14=2,28=2,SaleName_ID=2,SaleName=SeleB,SSD_ChargesType=2,SSD_SaleSetType=1,
    8=3,13=3,14=3,28=3,SaleName_ID=3,SaleName=SaleC,SSD_ChargesType=2,SSD_SaleSetType=1,
    8=4,13=4,14=4,28=4,SaleName_ID=4,SaleName=SeleD,SSD_ChargesType=2,SSD_SaleSetType=1,

    这明显列的顺序改变了。。。

    后来在官方找到了IE兼容性的一篇文章

    http://msdn.microsoft.com/en-us/library/ie/gg622937%28v=vs.85%29.aspx

    提到这一点,尼玛居然不给解决办法,心中的千万匹的草尼玛在奔腾...

    现在只能根据浏览器来判断重新写了,有哪位知道有好办法解决的给告诉一下啊

  • 相关阅读:
    iOS Mapkit 定位REGcode地理位置偏移
    制作mac U盘启动
    mac git xcrun error active developer path 错误
    xcode 修改 organization name 和 company identifier
    PHP 修改配置文件后重启命名
    使用 PHP 构建的 Web 应用如何避免 XSS 攻击
    PHP 可变变量
    使用 PHP 构建的 Web 应用如何避免 XSS 攻击
    git 放弃本地修改,强制拉取更新
    PHP smarty模版引擎基本安装
  • 原文地址:https://www.cnblogs.com/q149072205/p/3417889.html
Copyright © 2011-2022 走看看