ie7 xml ActiveXObject ErrorMessage: Object expected

J

JTree

Hi all,

My System is windows and ie version is 7.

My code:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<script type="text/javsscript">
<!--
var xmlDoc;

function LoadXml(){
if (Web.Application.get_type() ==
Web.ApplicationType.InternetExplorer) {

var progIDs = [ 'Msxml2.DOMDocument.6.0', 'Msxml2.DOMDocument.5.0',
'Msxml2.DOMDocument.4.0', 'Msxml2.DOMDocument.3.0',
'Msxml2.DOMDocument' ];

for (var i = 0; i < progIDs.length; i++) {
try {
xmlDOM = new ActiveXObject(progIDs);
return xmlDoc;
}
catch (ex) {
alert("ex.message");
}
}

return null;
}
}

function ProcessXml(){
if (window.ActiveXObject){
try{
//xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
LoadXml();
xmlDoc.async = false;
xmlDoc.load("url.xml");
}
catch(e)
{
alart(e.message);
}
} else if (document.implementation &&
document.implementation.createDocument){
xmlDoc = document.implementation.createDocument("", "" , null);
xmlDoc.load("url.xml");
//xmlDoc.onload = ShowXml;
} else {
alert("your browser cannot handle the script!");
}

ShowXml();
}

function ShowXml(){
//alert(xmlDoc.getElementsByTagName("url")
[0].childNodes[0].nodeValue);
}
-->
</script>
</head>
<body>
<form action="#">
<input type="button" name="process" id="process"
onclick="ProcessXml()" />
</form>
</body>
</html>

url.xml:
<?xml version="1.0" encoding="utf-8" ?>
<urls>
<url>
<obj>1</obj>
<priority>1</priority>
<loop>3</loop>
</url>
<url>
<obj>1</obj>
<priority>2</priority>
<loop>3</loop>
</url>
<url>
<obj>1</obj>
<priority>3</priority>
<loop>3</loop>
</url>
</urls>



When I click the button, the ie shows an error message "Object
expected". Is there any problem with my code?

Any suggestions would be appreciated!

Thanks!
 
P

Peter Michaux

Hi all,

My System is windows and ie version is 7.

My code:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<script type="text/javsscript">
<!--
var xmlDoc;

function LoadXml(){
if (Web.Application.get_type() ==
Web.ApplicationType.InternetExplorer) {

var progIDs = [ 'Msxml2.DOMDocument.6.0', 'Msxml2.DOMDocument.5.0',
'Msxml2.DOMDocument.4.0', 'Msxml2.DOMDocument.3.0',
'Msxml2.DOMDocument' ];

for (var i = 0; i < progIDs.length; i++) {
try {
xmlDOM = new ActiveXObject(progIDs);
return xmlDoc;
}
catch (ex) {
alert("ex.message");
}
}

return null;
}
}

function ProcessXml(){
if (window.ActiveXObject){
try{
//xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
LoadXml();
xmlDoc.async = false;
xmlDoc.load("url.xml");
}
catch(e)
{
alart(e.message);
}
} else if (document.implementation &&
document.implementation.createDocument){
xmlDoc = document.implementation.createDocument("", "" , null);
xmlDoc.load("url.xml");
//xmlDoc.onload = ShowXml;
} else {
alert("your browser cannot handle the script!");
}

ShowXml();
}

function ShowXml(){
//alert(xmlDoc.getElementsByTagName("url")
[0].childNodes[0].nodeValue);
}
-->
</script>
</head>
<body>
<form action="#">
<input type="button" name="process" id="process"
onclick="ProcessXml()" />
</form>
</body>
</html>

url.xml:
<?xml version="1.0" encoding="utf-8" ?>
<urls>
<url>
<obj>1</obj>
<priority>1</priority>
<loop>3</loop>
</url>
<url>
<obj>1</obj>
<priority>2</priority>
<loop>3</loop>
</url>
<url>
<obj>1</obj>
<priority>3</priority>
<loop>3</loop>
</url>
</urls>

When I click the button, the ie shows an error message "Object
expected". Is there any problem with my code?


Can you trim this HTML to about 15 lines and still reproduce the
problem?

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top