IE:无法获取属性'的值;clientWidth':对象为null或未定义

IE: Unable to get value of the property 'clientWidth': object is null or undefined

本文关键字:对象 null 未定义 clientWidth 的值 获取 属性 IE      更新时间:2024-02-09

错误消息仅显示在IE上,但似乎没有解决此问题的方法。

我已经将http-equiv="X-UA-Compatible"设置为IE8,但仍然无法使其工作。

我正在尝试使用jQuery来重新加载表的内容。但jQuery的重新加载显然无法设置clientWidth,因为jQuery中没有对应的术语。

<table style="" id="actionMap" class="top-table">

<table>的id属性用于DOM,class用于jQuery。

j(function() {
        j('#filter_workflows').change(function () {
            var workflow = j(this).val();
            var url = '<spring:url value="/actionMap" />' + '?filter_workflow=' + workflow;
            var savedWidth = document.getElementById("actionMap").clientWidth;
            j('table.top-table').load(url+' table.top-table > *');
            j('input[name=filter_workflow]').val(workflow);
            document.getElementById("actionMap").clientWidth = savedWidth;
        });
    });

事实证明属性clientWidth是只读的。

  document.getElementById("actionMap").clientWidth = savedWidth;

永远不会成功。

那么,在jQuery重新加载表之后,我们如何设置clientWidth属性呢?

感谢

这有帮助吗?

http://api.jquery.com/width/

clientWidth可能是特定于客户端的(它可以是特定于客户的,除了IE之外的所有东西都支持它…)

jQuery具有这些的包装器函数,请参阅http://api.jquery.com/category/dimensions/和http://api.jquery.com/category/offset/