Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    javascript error ActiveXObject("Microsoft.XMLDOM").load(filename)

    Hi

    I am trying to load html stream directly into webbrowser in delphi.
    The html contains java script. It loads xml and xsl files and display the xml content in the web browser.

    I got an error, says access denied for the command xmlDoc.load(fname);

    If I save the html into a file, test.html, and double click it, it is fine, no problem.

    The code is actually copied from w3schools.com.

    the html code as followed:
    <html>
    <head>
    <script>
    function loadXMLDoc(fname){var xmlDoc;
    if (window.ActiveXObject)
    {
    xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
    }
    else
    {
    alert('Your browser cannot handle this script');
    }
    xmlDoc.async=false;
    xmlDoc.load(fname);
    return(xmlDoc);
    }

    function displayResult()
    {
    xml=loadXMLDoc("catalog.xml");
    xsl=loadXMLDoc("catalog.xsl");
    if (window.ActiveXObject)
    {
    ex=xml.transformNode(xsl);
    document.getElementById("example").innerHTML=ex;
    }
    }
    </script>
    </head>
    <body id="example" onLoad="displayResult()">
    </body>
    </html>


    The delphi code is

    procedure TForm1.WBLoadHTML(WebBrowser: TWebBrowser; HTMLCode: string) ;
    var
    v: OleVariant;
    HTMLDocument: IHTMLDocument2;
    begin
    memo1.Lines.LoadFromFile('d:\test\htmltxtold.html');
    HTMLCode := memo1.Text;

    WebBrowser1.Navigate('about:blank') ;
    HTMLDocument := WebBrowser.Document as IHTMLDocument2;
    v := VarArrayCreate([0, 0], varVariant);
    v[0] := HTMLCode;
    HTMLDocument.Write(PSafeArray(TVarData(v).VArray));
    HTMLDocument.Close;
    end;


    Thanks a lot

  • #2
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Getting same issue with ActiveXObject

    I am getting same error with IE7, but it is executing in firefox... where is the error.. please tell me


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •