Results 1 to 2 of 2

Thread: Delphi, TWebBrowser & Java Scripts.

  1. #1
    Join Date
    Jul 2010
    Posts
    37

    Delphi, TWebBrowser & Java Scripts.

    Can TWebBrowser launches Java scripts. Let's say, the web-site is made of 2 or 3 Java applications: App1, App2 and App3.

    Can I tell that TWebBrowser load just App3, for example?

  2. #2
    Join Date
    Dec 2007
    Posts
    2,291

    Re: Delphi, TWebBrowser & Java Scripts.

    Code:
    uses
      MSHTML;
      
    procedure TForm1.CallFoo(S: string; I: Integer);
      { Calls JavaScript foo() function }
    var
      Doc: IHTMLDocument2;      // current HTML document
      HTMLWindow: IHTMLWindow2; // parent window of current HTML document
      JSFn: string;             // stores JavaScipt function call
    begin
      // Get reference to current document
      Doc := WebBrowser1.Document as IHTMLDocument2;
      if not Assigned(Doc) then
        Exit;
      // Get parent window of current document
      HTMLWindow := Doc.parentWindow;
      if not Assigned(HTMLWindow) then
        Exit;
      // Run JavaScript
      try
        JSFn := Format('foo("%s",%d)', [S, I]);  // build function call
        HTMLWindow.execScript(JSFn, 'JavaScript'); // execute function
      except
        // handle exception in case JavaScript fails to run
      end;
    end;
    More information can be found here.

Similar Threads

  1. TWebBrowser popup window Problem (Delphi)
    By lucky3664 in forum Software Development
    Replies: 2
    Last Post: 06-03-2012, 11:25 AM
  2. Delphi, TWebBrowser, Centralized Window?!
    By alex198555 in forum Software Development
    Replies: 3
    Last Post: 29-07-2010, 11:21 AM
  3. Delphi, TWebBrowser, Web-Site Login?!
    By alex198555 in forum Software Development
    Replies: 1
    Last Post: 28-07-2010, 11:11 AM
  4. Delphi, TWebBrowser, Disable Scrollbars???
    By alex198555 in forum Software Development
    Replies: 4
    Last Post: 26-07-2010, 11:02 PM
  5. Delphi, TWebBrowser, Auto-Refresh???
    By alex198555 in forum Software Development
    Replies: 3
    Last Post: 22-07-2010, 10:41 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,213,762.31743 seconds with 17 queries