twebbrowser

Detecting external content with TEmbeddedWB or TWebBrowser

我们两清 提交于 2019-12-21 05:39:23
问题 I am trying to block anything external loaded by TEmbeddedWB or TWebBrowser (or TCppWebBrowser). I would like to block anything that is loaded from Internet including images, javascript, external CSS, external [embed] or [object] or [applet] or [frame] or [iframe], executing JavaScript that can load external content etc. This problem consists of 2 parts: putting web browser into "restrict all" (except basic HTML without images) and detecting if such content exists if external content is not

How do I set each TWebBrowser to use an independent proxy?

老子叫甜甜 提交于 2019-12-18 16:50:40
问题 I have found all kind of examples about how to make TWebBrowser use a proxy (like 202.8.128.5:8080). However all those examples are changing the proxy globally for all running instances of TWebBrowser. I have two instances. How do I set a different proxy for each browser? 回答1: This can be achieved using the following code (public code, not mine): {$DEFINE DELPHI2009_UP} function SetProxy(Server: String): Boolean; // Server z.B. '127.0.0.1:8080' oder '' type INTERNET_PER_CONN_OPTION = record

How to select <option> item by the “value” attribute in <select> drop-down list?

一曲冷凌霜 提交于 2019-12-18 06:11:45
问题 In my Delphi application I'm using a TWebBrowser control, where I have loaded an HTML document, containing a <select> element (drop down list) with a few <option> items (drop down list items). Let's say, I have the following HTML document loaded in my web browser: <html> <body> <select id="ComboBox"> <option value="firstvalue">First Value</option> <option value="secondvalue">Second Value</option> <option value="thirdvalue">Third Value</option> </select> </body> </html> How can I

How can I get HTML source code from TWebBrowser

☆樱花仙子☆ 提交于 2019-12-18 04:42:42
问题 How can I get source code from WebBrowser component? I want to get source code of active page on WebBrowser component and write it to a Memo component. Thanks. 回答1: You can use the IPersistStreamInit Interface and the save method to store the content of the Webbrowser in a Stream. Uses ActiveX; function GetWebBrowserHTML(const WebBrowser: TWebBrowser): String; var LStream: TStringStream; Stream : IStream; LPersistStreamInit : IPersistStreamInit; begin if not Assigned(WebBrowser.Document) then

Javascript in Delphi TWebBrowser, Closing Threads

孤人 提交于 2019-12-18 02:47:55
问题 I am attempting to build a system in delphi that allows users to use Google Maps. It all works fine, but i'm noticing that every time a new TWebBrowser object is created and the javascript that handles Google Maps is loaded, a number of new Threads is generated. My problem is that even once the webbrowser is destroyed (and it is definately destroyed) the created threads persist. I'm designing this program to have long running times and the opening and closing of google maps to happen many

TWebBrowser crashes with embedded Youtube clips

杀马特。学长 韩版系。学妹 提交于 2019-12-17 19:47:42
问题 Here is my code: type TForm1 = class(TForm) WebBrowser1: TWebBrowser; Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); end; implementation uses ActiveX; procedure TForm1.Button1Click(Sender: TObject); // method 1 var HtmlFile: string; begin HtmlFile := ExtractFilePath(Application.ExeName) + 'test.html'; WebBrowser1.Navigate(HtmlFile); end; procedure LoadHtml(wb: TWebBrowser; HTMLStr: string); var aStream: TMemoryStream;

A way to redirect keypresses from TWebBrowser to the ParentForm

坚强是说给别人听的谎言 提交于 2019-12-14 03:56:56
问题 First question. Help format it, if needed, please. Context I have a TWebBrowser in the main form that is used to behave like it was a printer. So I load some HTML text in it as user do some commands in the real printer... I want the user to be able to click and select text from the WebBrowser. Problem When the user clicks in the WebBrowser some of the shortcuts registered from the actions don't work anymore. For example, there is an action with shortcut F7 . If the user clicks in the

How to click Button Class WebBrowser Delphi

…衆ロ難τιáo~ 提交于 2019-12-13 19:47:44
问题 How to click in this button in TWebBrowser on Delphi <button class="btn btn-primary btn-block" type="button" onclick="login()">Sign in</button> 回答1: I do not have a Delphi compiler right now. The code is written using brain compiler. But it should work in general. Use OleObject You can use oleobject interface to access the DOM. var Buttons: OleVariant; Button: OleVariant; I: Integer; begin Buttons := WebBrowser1.OleObject.Document.getElementsByTagName("button"); for I := 0 to Buttons.Length -

Delphi TWebBrowser Memory Leak

断了今生、忘了曾经 提交于 2019-12-13 12:12:22
问题 My application uses a TWebBrowser that loads a webpage. The problem is, after closing the form containing the TWebBrowser, the memory used is not freed. If I open and close the form, the memory just keeps on increasing. Saw some post regarding calling SetProcessWorkingSetSize() or CoFreeUnusedLibrariesEx() to solve this issue, but I'm not sure if any of these are the correct solution. Any idea how to free the memory used by TWebBrowser? 回答1: QC#106829 describes one possible cause of memory

Executing JS in TWebBrowser

穿精又带淫゛_ 提交于 2019-12-13 04:59:17
问题 I take http://www.foxbase.ru/delphi/javascript-na-delphi.htm worked example and trying to execute my own js code. Some corrections and its simly like this : http://shadow-core.com/ShadowJS.pas Firstly , i dont know where is problem... Cuz , in source code in example, we simply use: js:=TDelphiJS.Create; js.LoadFromURL('http://vbulletin_forum.ru/clientscript/vbulletin_md5.js?v=371'); js.DeclareVariable('mypassword'); js.DeclareVariable(''); js.DeclareVariable(''); js.DeclareVariable(''); js