DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> AJAX入門 >> AJAX詳解 >> 建立XMLHttpRequest對象
建立XMLHttpRequest對象
編輯:AJAX詳解     

utl.JS


[復制此代碼]CODE:function createXMLTree(node, indent) {
    if (node == null)
        return "";
    var str = "";
    switch (node.nodeType) {
        case 1:    // Element
            str += " <" + node.nodeName + "";
            var attrs = node.attributes;
            for (var i = 0; i < attrs.length; i++)
                str += createXMLAttribute(attrs[i]);
            if (!node.hasChildNodes())
                return str + "/>";
            str += ">
";
            var cs = node.childNodes;
            for (var i = 0; i < cs.length; i++)
                str += createXMLTree(cs[i], indent + 3);
            str += "            break;
        case 9:    // Document
            var cs = node.childNodes;
            for (var i = 0; i < cs.length; i++)
                str += createXMLTree(cs[i], indent);
            break;
        case 3:    // Text
            if (!/^\s*$/.test(node.nodeValue))
                str += "" + node.nodeValue + "
";
            break;
        case 7:    // ProcessInstruction
            str += "            var attrs = node.attributes;
            for (var i = 0; i < attrs.length; i++)
                str += createXMLAttribute(attrs[i]);
            str+= "?>
"
            break;
        case 4:    // CDATA
            str = "                 node.nodeValue +
            "]" + "]>";
            break;
        case 8:    // Comment
            str = " ";
            break;
        case 10:
                str = "                     if (node.systemId) 
                        str += " \"" + node.systemId + "\"";
                }
                else if (node.systemId) {
                    str += " SYSTEM \"" + node.systemId + "\"";
                }
                str += ">";
                // TODO: Handle custom DOCTYPE declarations (ELEMENT, ATTRIBUTE, ENTITY)
                break;
        default:
            //alert(node.nodeType + "\n" + node.nodeValue);
            inspect(node);
    }
    return str;
}
function inspect(obj) {
    var str = "";
    for (var k in obj)
        str += "obj." + k + " = " + obj[k] + "\n";
    window.alert(str);
}
function createXMLAttribute(a) {
    return " " + a.nodeName + "=\"" + a.nodeValue + "\"";
}
[復制此代碼]CODE:



rel=stylesheet>


[復制此代碼]CODE:
Html {
 BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px
}
BODY {
 BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px
}
BODY {
 BACKGROUND: buttonface; FONT: Message-Box
}
FORM {
 PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px
}
FIELDSET FIELDSET {
 MARGIN: 5px
}
BUTTON {
 MARGIN-LEFT: 5px
}
TEXTAREA {
 WIDTH: 100%; HEIGHT: 200px
}
#out {
 BORDER-RIGHT: threeddarkshadow 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: threeddarkshadow 1px solid; MARGIN-TOP: 5px; PADDING-LEFT: 3px; BACKGROUND: white; PADDING-BOTTOM: 3px; BORDER-LEFT: threeddarkshadow 1px solid; COLOR: black; PADDING-TOP: 3px; BORDER-BOTTOM: threeddarkshadow 1px solid; FONT-FAMILY: Verdana
}
#srcTextContainer {
 DISPLAY: none
}
.element {
 PADDING-LEFT: 16px; COLOR: blue
}
.elementname {
 COLOR: darkred
}
.attribname {
 COLOR: red
}
.attribvalue {
 COLOR: blue
}
.text {
 PADDING-LEFT: 16px; COLOR: windowtext
}
.cdata-content {
 DISPLAY: block; PADDING-LEFT: 16px; BORDER-LEFT: gray 1px solid; COLOR: windowtext; FONT-FAMILY: CourIEr New; WHITE-SPACE: pre
}
.comment {
 PADDING-LEFT: 16px; COLOR: blue
}
.doctype {
 PADDING-LEFT: 16px; COLOR: blue
}
.comment-content {
 DISPLAY: block; COLOR: gray; FONT-FAMILY: CourIEr New; WHITE-SPACE: pre
}
#XMLDebug {
 BORDER-RIGHT: #000 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: #000 1px solid; MARGIN-TOP: 6px; PADDING-LEFT: 4px; FONT-SIZE: 12px; BACKGROUND: #fff; PADDING-BOTTOM: 4px; OVERFLOW: auto; BORDER-LEFT: #000 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: #000 1px solid; HEIGHT: 400px
}

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved