信息:& # 39;ActiveXOjbect& # 39;是未定义的

Message: 'ActiveXOjbect' is undefined

本文关键字:未定义 ActiveXOjbect 信息      更新时间:2023-09-26
<?xml version = "1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/tr/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en">
    <head>
        <title>Finding Element Values in an XML Document</title>
        <script language = "javascript" type = "text/javascript">
            function getStudentData(){
                var xmlDoc;
                xmlDoc = new ActiveXOjbect("Microsoft.XMLDOM");
                xmlDoc.load("School.xml");
                nodeSchool = xmlDoc.documentElement;
                nodeClass = nodeSchool.firstChild;
                nodeStudents = nodeClass.lastChild;
                nodeStudent = nodeStudents.lastChild;
                nodeFirstName = nodeStudent.firstChild;
                nodeLastName = nodeFirstName.nextSibling;
                outputMessage = "Name: " + nodeFirstName.firstChild.nodeValue + " " + nodeLastName.firstChild.nodeValue;
                message.innerHTML = outputMessage;
            }
        </script>
    </head>
    <body>
        <center>
            <h1>Finding Element Values in an XML Document</h1>
            <div id = "message"></div>
            <p>
                <input type = "button" value = "Get Second Student's Name" onClick = "getStudentData()" />
            </p>
        </center>
    </body>
</html>

给出如下错误

网页错误详情

User Agent: Mozilla/4.0 (compatible;MSIE 8.0;Windows NT 6.1;三叉戟/4.0;SLCC2;.net CLR 2.0.50727;.net CLR 3.5.30729;net CLR3.0.30729;Media Center PC 6.0;InfoPath.2) Timestamp: Fri, 11 Jan 2013 14:33:05 UTC

消息:' activexjject ' is undefined Line: 19 Char: 5 Code: 0 URI:文件:///D:/Priyal/个人/程序/XHTML/XML/School.html

消息:' activexjject ' is undefined Line: 19 Char: 5 Code: 0 URI:文件:///D:/Priyal/个人/程序/XHTML/XML/School.html

你打错了。

ActiveXObject代替ActiveXOjbect

但是你也应该注意到ActiveXObject在Internet Explorer中只有可用。所有其他浏览器都会抛出相同的错误。