Embedded Web browser prevents pop-up advertisements, windows, and other technologies

Source: Internet
Author: User
  • Check whether an advertisement is automatically displayed in the pop-up window

In the onstatustextchange event processing function of the tembeddedwb control, save the text parameter. If a new window does not pop up automatically but is clicked by the user, the URL on the page in the new window is saved in this parameter. Therefore, you can compare the URL to determine.

procedure TForm1.wbMainStatusTextChange (ASender: TObject;  const Text: WideString);begin  mStatusText := Text;end;

 

  • Block A new window that will pop up by default

In the function triggered by the onnewwindow3 event of the tembeddedwb control, temporarily cancel the creation of a new window. After judging that the new window is not an advertisement, the browser control in the current window will access the pop-up webpage, in this way, the webpage pop-up is blocked.

Procedure tform1.wbmainnewwindow3 (asender: tobject; var ppdisp: idispatch; var cancel: wordbool; dwflags: Cardinal; const bstrurlcontext, bstrurl: widestring); begin cancel: = true; if (bstrurl = mstatustext) Then // you can click wbin wbmain. navigate (bstrurl); end;

 

  • Determine whether the entire webpage has been read (excluding the impact of frame/iframe)

When the ondocumentcomplete event of the tembeddedwb control is triggered, the webpage has been read. However, if the webpage contains the frame/IFRAME element, the ondocumentcomplete event is triggered when the webpage reading in each frame/iframe is complete. To eliminate the interference of these frame/iframe, you need to add a judgment when the ondocumentcomplete event is triggered to determine whether the entire webpage is complete.

Procedure tform1.wbmaindocumentcomplete (asender: tobject; const Pdisp: idispatch; var URL: olevariant); begin if (wbmain. application = Pdisp) then begin // todo: add the required code end; end here;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.