salvadordf / WebView4Delphi

WebView4Delphi is an open source project created by Salvador Díaz Fau to embed Chromium-based browsers in applications made with Delphi or Lazarus/FPC for Windows.
https://www.briskbard.com/forum/
MIT License
280 stars 56 forks source link

UserAgent is not changed if i open link that has target='_blank' #47

Closed ZeroGit2015 closed 7 months ago

ZeroGit2015 commented 7 months ago

UserAgent is not changed if i open link that has target='_blank'

P.S. target = 'blank' works correctly.

salvadordf commented 7 months ago

Use the PopupBrowser demo and set the user agent before setting FArgs.NewWindow.

Read these code comments for more details about the NewWindow property : https://github.com/salvadordf/WebView4Delphi/blob/0a94a1a42e91021844902acbe91d7755735ea90b/source/uWVTypeLibrary.pas#L5036

The UserAgent property may be overridden if the User-Agent header is set in a request : https://github.com/salvadordf/WebView4Delphi/blob/0a94a1a42e91021844902acbe91d7755735ea90b/source/uWVTypeLibrary.pas#L11873

ZeroGit2015 commented 7 months ago

i tried demo, but this demo has same problem. If tag A has attribute target='_blank' user agent on new page no changes(when we click on this A). If tag A has target='blank' everything works correctly.

salvadordf commented 7 months ago

We don't have access to all the source code of WebView2 and this looks like a WebView2 feature/issue. If the suggestions in my previous message don't work then this is an upstream issue.