使用IE8时,页面刷新时不显示更改

时间:2013-12-31 09:13:36

标签: javascript jquery asp.net knockout.js internet-explorer-8

我编写了一些JavaScript函数,当点击一个按钮时,它会做两件事:

  1. 它会将按钮的标签从“激活”更改为“取消激活”,反之亦然。
  2. ActiveStatus属性的值将从1更改为0,反之亦然。
  3. 代码工作正常,并且更改在Mozilla Firefox中完美显示,但每当我尝试在IE 8中显示页面时,都不会显示更改,但在数据库中,值会更改。

    以下是按钮点击的JavaScript代码:

    $(function () {
    
    
        var stat = document.getElementById("stat").value;
        //alert(stat);
    
        if (stat == 1)
            document.getElementById("butt").value = "Activate";
        else
            document.getElementById("butt").value = "Deactivate";
    });
    
    
    
    
    function activeStatus(ActiveStatus) {
    
        //alert(ActiveStatus);
        if (ActiveStatus == 1) {
            return "Activate";
        }
        else
        return "Deactivate";
    }
    
    function change() {
    
        var butt = document.getElementById("butt").value;
    
        if (butt == 'Deactivate') {
            document.getElementById("butt").value = "Activate";
            document.getElementById("stat").value = 1;
        }
    
        else {
            document.getElementById("butt").value = "Deactivate";
            document.getElementById("stat").value = 0;
        }
    }
    

    此外,每当我尝试在IE 8中查看页面时,我收到的异常消息是:

    Microsoft JScript runtime error: Object doesn't support this property or method
    

    我在Country.js JavaScript文件中收到此错误。我得到这个例外的地方是:

    var url = "/Country/GetAllCountry";
        var refresh = function () {
            $.getJSON(url, {}, function (data) {
                self.Countries(data);
            });
        };
    

    更具体地说,在这一行:

    self.Countries(data);    
    

    当我尝试在Firefox中运行我的应用程序时,这些都不会发生。当我尝试在IE 8中运行我的应用程序时,所有这些都会发生。

    为什么我要面对这个问题????

    编辑-1:我部分地解决了我的问题。例外:

    Microsoft JScript runtime error: Object doesn't support this property or method
    
    显示

    只是因为Country.js中未定义'Countries'。国家必须是有效的可观察者,但必须予以宣布。我只需要在它旁边添加这行代码,执行声明:

    self.Countries = ko.observableArray([]);
    

    现在异常消失了,单击按钮后页面仍然没有刷新。

1 个答案:

答案 0 :(得分:0)

这个问题的答案来自以下5个简单步骤:

  1. 选择工具>>互联网选项。
  2. 点击浏览历史记录中的设置按钮。
  3. 选择每次访问网页单选按钮。
  4. 单击“确定”关闭“设置”对话框。
  5. 单击“确定”关闭“Internet选项”对话框。
  6. 现在效果很好。

    礼貌:Gonzalo(https://stackoverflow.com/users/203766/gonzalo

相关问题