Document not available

Discussion in 'JavaScript' started by aulio, Jan 8, 2007.

  1. #1
    I have a script which loads local XML file as follows:

    doc = document.implementation.createDocument("", "", null);
    doc.load(file);
    Code (markup):
    When I try to access the DOM it's not available. How can I ensure that document is loaded before access it?

    I already tried following:

    function wait()
    {
      if (doc == null)
        id = setTimeout(wait(),100);
      else
        doMyStuff();
    }
    Code (markup):
    But it just gave me the "too much recursion" error.

    Only way I've gotten it to work is to call alert after load. The document is available after I've clicked ok. What does that indicate?
     
    aulio, Jan 8, 2007 IP