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

Discussion in 'Javascript' started by gal.granov@gmail.com, Dec 6, 2004.

  1. Guest

    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
    }
    , Dec 6, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. CRON
    Replies:
    24
    Views:
    200,655
    Adrienne Boswell
    Jun 20, 2006
  2. Johnny
    Replies:
    3
    Views:
    453
    Robert Kern
    Aug 23, 2005
  3. Hari Sekhon
    Replies:
    0
    Views:
    501
    Hari Sekhon
    Jun 20, 2006
  4. Vinko Vrsalovic

    int func() v/s int func(void)

    Vinko Vrsalovic, Jan 21, 2005, in forum: C Programming
    Replies:
    14
    Views:
    1,304
    Villy Kruse
    Jan 24, 2005
  5. Replies:
    37
    Views:
    463
Loading...

Share This Page