Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

How to execute js in popup

Post Reply
dvbss11
Posts: 28
Joined: Sat Oct 26, 2019 6:30 pm

How to execute js in popup

Post by dvbss11 »

Tell me how you can execute js script in a popup window. How to contact him?

The problem is that blocking the pop-up window and using the new tab does not help, because the site on which it all happens cookies are sent to the main window after clicking authorization in the pop-up window.

If done through a new tab, then only the window remains that asks to close the window. After closing the authorization window on the site does not occur.

Here are the manual steps
1. Go to the site
2. Click on the authorization button
3. Popup window pops up
4. Enter the login password in the window
5. Click send
6. Popap closes
7. Login is successful.



How to execute js in popup?
or some other way tell me.

Checked in browsers in which pop-ups are disabled, there opens a new tab. After authorization, it automatically closes. But in the MiniBrowser examples, this does not work. After sending authorization, the button window remains (close the window); if clicked, the tab closes. But in the next tab there is no authorization.
User avatar
salvadordf
Posts: 4040
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to execute js in popup

Post by salvadordf »

Hi,

Please, download the official CEF "Sample Application" from here :
http://opensource.spotify.com/cefbuilds ... nt.tar.bz2

Test your web page with the "Sample Application".

Some web pages create popup windows and they keep a reference to the new window to modify it after it has been created. This is an example :
https://www.w3schools.com/jsref/tryit.a ... _win_open3

That example works on the MiniBrowser demo because the popup window is created automatically by CEF.

This is another example that works on MiniBrowser. This example can close the popup window from a button in the main browser :
https://www.w3schools.com/jsref/tryit.a ... _win_close

If the web page you mention uses a similar method to allow users to login then it should work in MiniBrowser too.

If you're using an old CEF4Delphi version then check that MiniBrowser is setting GlobalCEFApp.cache before the GlobalCEFApp.StartMainProcess call in the DPR file.

If you prefer to handle the new popups then you need to use the code in the PopupBrowser2 demo.
In this case you need to create hidden child forms and use them when the browser wants to create a new popup window.
As you know, CEF events are executed in a different thread and you can't create and destroy controls in different threads.
PopupBrowser2 uses the TChromium.OnBeforePopup event which is executed in a CEF thread to create new popups but TMainForm.Chromium1BeforePopup only calls "CreateClientHandler" in the hidden form to initialize the child browser.

Read the code comments in that demo for more details.

If your application is creating tabs instead of child forms then you would need to create hidden tabs and call "CreateClientHandler" in the TChromium.OnBeforePopup event to initialize them.
Post Reply