Safarfi document.load() - can i create the unsupported load func myself?

G

gal.granov

Hi,

i am trying to create an XML wrapper for the IE, Mozilla and Safari.

the interface i want to support is :

myDoc.load("data.xml")

this works fine on IE & NN , but i've read and seen myself, that the
Safari browser does not support the XMLDOC load method.

i am trying to write my own version of this function:

Document.prototype.load= MyLoadFunc;


but safari with it's "wonderful" debug facilities doesnt seem to be
happy with it.
and all i get in the console (debug sent there) is :

TypeError - undefined value.

can i insert this new load func into the Document interface in safari?





where MyLoadFunc is defined as:


function MyLoadFunc(strURL)
{
alert("here");
//set the parseError to 0
this.parseError = 0;

//change the readyState
this.readyState = 1;

//watch for errors
try {
if(this.async == false)
{
//create XMLHttpRequest object
var req = new XMLHttpRequest();
req.open("GET", strURL , false);
req.overrideMimeType("text/xml");

// Execute the request
req.send(null);

//check the returning status
if(req.status>400 || req.status < 200)
{
//set the parseError attribute
this.parseError = -9999999;

//change the readystate
this.readyState = 4;

//call to the onreadystatechange
if (typeof (this.onreadystatechange) == "function")
this.onreadystatechange();
}
else
{
this.loadXML(req.responseText);

//change the readystate
this.readyState = 4;

//call to the onreadystatechange
if (typeof (this.onreadystatechange) == "function")
this.onreadystatechange();
}
}
else
{
//call the original load method
this.OldLoad(strURL);
}
}
catch (objException)
{
//set the parseError attribute
this.parseError = -9999999;

//change the readystate
this.readyState = 4;

//call to the onreadystatechange
if (typeof (this.onreadystatechange) == "function")
this.onreadystatechange();
} // End: try...catch
}
 

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