Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Webbrowser code collection

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

1. Forbid the new Webbrowes window to open the page, forcing it to open on the current page.

Method: put two webbrowser controls with the following error code

Procedure TForm1.WebBrowser1NewWindow2 (Sender: TObject; var PpDisp: IDispatch; var Cancel: WordBool); begin PpDisp: = WebBrowser2.Application;end;procedure TForm1.WebBrowser2BeforeNavigate2 (Sender: TObject; const PDisp: IDispatch; var URL, Flags, TargetFrameName, PostData, Headers: OleVariant; var Cancel: WordBool); var urlStr: string;begin urlStr: = string (URL); WebBrowser1.Navigate (urlStr); Cancel: = True;end; take all connections in USER to join MSHTML; and ActiveX;procedure TForm1.Button2Click (Sender: TObject); vardoc:IHTMLDocument2;all:IHTMLElementCollection Len,i:integer;item:OleVariant;begindoc:=WebBrowser1 .document as IHTMLDocument2;all:=doc.Get_links;//doc.Linkslen:=all.length;for iVarempty (to len-1 do beginitem:=all.item); / / EmpryParammemo1.lines.add (item.href); end;end / get the source code of the web page Memo1.Text:=WebBrowser1.OleObject.document.documentelement.innerhtml / prohibit advertising from popup procedure TForm1.WebBrowser1NewWindow2 (Sender: TObject;var ppDisp: IDispatch; var Cancel: WordBool); begincancel:=trueend / enter procedure TForm1.WebBrowser1NewWindow2 directly without a pop-up window (Sender: TObject;var ppDisp: IDispatch; var Cancel: WordBool); varNewApp: TForm1 BeginNewApp: = TForm1.Create (Owner); NewApp.Visible: = true;ppdisp: = NewApp.webbrowser1.Application End/ read-only text procedure TForm1.Button1Click (Sender: TObject); varHTMLDocument: IHTMLDocument2;begin HTMLDocument: = WebBrowser1.Document as IHTMLDocument2 Memo1.Text: = HTMLDocument.body.innerText;end;/ copy uses Activex You can add the following anywhere. Initialization oleinitialize (nil); finalization oleuninitialize;/ Select all and copy procedure TForm1.Button2Click (Sender: TObject) BeginWebBrowser1.ExecWB (OLECMDID_SELECTALL, OLECMDEXECOPT_PROMPTUSER, EmptyParam, EmptyParam); / / Select all WebBrowser1.ExecWB (OLECMDID_COPY, OLECMDEXECOPT_PROMPTUSER, EmptyParam, EmptyParam); / / copy to the drop-down box and radio uses mshtml;varHtmlDoc:IHTMLDocument2;myitem:Olevariant;i:integer;beginmyitem: = WebBrowser1.Document in the clipboard end; submission form For I: = 0 to myitem.all.length-1 dobeginif myitem.all.item (I). TagName = 'SELECT' then / / drop-down box Select beginmyitem.all.item (I). Value:='2'; / /' 2' is value= "content end If myitem.all.item (I) .tagName = 'INPUT' thenbeginif Uppercase (myitem.all.item (I) .type) =' RADIO' thenbeginif myitem.all.item (I) .value = 'ask' then myitem.all.item (I) .value: = true;end;end;end;end; varo: Olevariant;begino: = WebBrowser.OleObject.document.all.item ('LoginUserID',0); / / find the input box of the login user name o.value: =' TEST' O: = WebBrowser.oleobject.document.all.item ('LoginPassword',0); / / find the entry box of the login password o.value: =' TEST'WebBrowser.oleobject.document.Forms.Item (0,0) .submit; / / the first form submission {o: = WebBrowser.oleobject.document.all.item ('Login',0); / / or submit o.Click with the specified form name; / / Click, the same can be done for other objects} end Call the JAVASCRIPT function WebBrowser1.OleObject.document.parentWindow.execScript ('GSLogin ()', 'javascript'); input multiple frames, and FrameIndex is the serial number of Frame var o: Olevariant; begin / / find the input box of login user name o: = WebBrowser.oleobject.document.documentelement.document.frames.item (FrameIndex) .document.all.item (' LoginUserID',0); o.value: = 'TEST' / / find the entry box for login password o: = WebBrowser.oleobject.document.documentelement.document.frames.item (FramIndex) .document.all.item ('LoginPassword',0); o.value: =' TEST' / / the first form submission WebBrowser.oleobject.document.documentelement.document.frames.item (FramIndex) .document.Forms.Item (0,0). Submit {/ / or submit o: = WebBrowser.oleobject.document.documentelement.document.frames.item (FramIndex).. document.all.item ('Login',0) with the specified form name; o.Click; / / Click, which can also be done on other objects} end;WebBrowser1.oleobject.Document.getElementById (' button') .Click / the first item is female (0 start) WebBrowser1.OleObject.document.getElementsByTagName ('input'). Item (1). Click Or use name, but name wants a unique WebBrowser1.OleObject.document.all.item ('Registered1'). Click

Http://www.cnblogs.com/xe2011/p/3144861.html( about Twebbrowers operation)

Determine whether the Radio in Webbrowes is selected

Source code of web page:

Set one before the end of the tail Pre-determined two Middle belly After the decision one After the second decision

If Web1.OleObject.document.Frames.item (0). Document.all.item ('typeTab',2). Checked then

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report