日期:2014-05-17  浏览次数:20408 次

vs2005页面调用jQuery在IE8报:对象不支持此属性或方法
如题,
C# code

<link rel="stylesheet" href="demoStyle/demo.css" type="text/css"/>
  <link rel="stylesheet" href="ztreeStyle/ztreeStyle.css" type="text/css"/>
  <script type="text/javascript" src="jquery-1.4.2.js"></script>
  <script type="text/javascript" src="jquery.ztree-2.6.js"></script>
  <script type="text/javascript" src="asyncData/demoData.js"></script>
  <script type="text/javascript" src="demoTools.js"></script>
  <script language="JavaScript">
    var ztree1, ztree2;
    var setting;

        setting = {
            editable: true,
            edit_renameBtn:false,
            edit_removeBtn:false,
            dragCopy: true,
            dragMove: true,
            callback: {
                click:    ztreeOnClick,
                drop: ztreeOnDrop
            }
        };

    $(document).ready(function(){
        reloadtree();
    });

    var preSelectedNode1;
    var preSelectedNode2;

    function ztreeOnClick(event, treeId, treeNode) {
        if (treeId=="treeDemo") {
            if (preSelectedNode1 == treeNode) {
                ztree1.cancelSelectedNode();
                preSelectedNode1 = null;
            } else {
                preSelectedNode1 = treeNode;
            }
        } else {            
            if (preSelectedNode2 == treeNode) {
                ztree2.cancelSelectedNode();
                preSelectedNode2 = null;
            } else {
                preSelectedNode2 = treeNode;
            }
        }
    }

    function ztreeOnDrop(event, treeId, treeNode, targetNode, moveType) {
        preSelectedNode1 = ztree1.getSelectedNode();
        preSelectedNode2 = ztree2.getSelectedNode();
    }

    function movetreeL2R() {
        movetreeNode(ztree1, ztree2);
    }
    
    function movetreeR2L() {
        movetreeNode(ztree2, ztree1);
    }
    
    function movetreeNode(srctree, targettree) {
        var srcNode = srctree.getSelectedNode();
        if (!srcNode) {
            alert("请先选择需要移动的节点!");
            return;
        }
        var targetNode = targettree.getSelectedNode();
        srctree.removeNode(srcNode);        
        targettree.addNodes(targetNode, [srcNode]);
        targettree.selectNode(srcNode);        
    }

    function reloadtree() {
        ztree1 = $("#treeDemo").ztree(setting, zNodes);
        ztree2 = $("#treeDemo2").ztree(setting, zNodes);
    }
  </script>


在这一行ztree1 = $("#treeDemo").ztree(setting, zNodes);报对象不支持此属性或方法,请高手解答,谢谢。

------解决方案--------------------
IE7如果不报错,请使用兼容模式